本文整理汇总了C#中Moq.Mock.SetupProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Moq.Mock.SetupProperty方法的具体用法?C# Moq.Mock.SetupProperty怎么用?C# Moq.Mock.SetupProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moq.Mock
的用法示例。
在下文中一共展示了Moq.Mock.SetupProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildReturnsCallableDelegate
public void BuildReturnsCallableDelegate()
{
var builder = new ApplicationBuilder(null);
var app = builder.Build();
var mockHttpContext = new Moq.Mock<HttpContext>();
var mockHttpResponse = new Moq.Mock<HttpResponse>();
mockHttpContext.SetupGet(x => x.Response).Returns(mockHttpResponse.Object);
mockHttpResponse.SetupProperty(x => x.StatusCode);
app.Invoke(mockHttpContext.Object);
Assert.Equal(mockHttpContext.Object.Response.StatusCode, 404);
}
示例2: Login_AdminPassword_True
public void Login_AdminPassword_True()
{
var dummyUser = new Moq.Mock<User>();
dummyUser.SetupProperty(user => user.Email, "[email protected]")
.SetupProperty(user => user.Password, "password");
User userObject = dummyUser.Object;
Assert.AreNotEqual(null, userObject.login("[email protected]", "password"));
}
示例3: createStaffMock
/**
* Create Mock Staff Object for test purposes
*/
private Staff createStaffMock()
{
var dummyStaff = new Moq.Mock<Staff>();
dummyStaff.SetupProperty(staff => staff.FirstName, "First")
.SetupProperty(staff => staff.LastName, "Last")
.SetupProperty(staff => staff.Role, "Agent")
.SetupProperty(staff => staff.DistributionCentre, new DistributionCentre());
return dummyStaff.Object;
}
示例4: createMockMedication
/**
* Addition method to create a mock object
* */
private MedicationStandardType createMockMedication()
{
var dummyMedication = new Moq.Mock<MedicationStandardType>();
dummyMedication.SetupProperty(medication => medication.Quantity, 100)
.SetupProperty(medication => medication.Description, "Medication Pills")
.SetupProperty(medication => medication.Cost, 30.00)
.SetupProperty(medication => medication.IsTempSensitive, false)
.SetupProperty(medication => medication.ShelfLife, "12/12/17");
return dummyMedication.Object;
}
示例5: BuildReturnsCallableDelegate
public void BuildReturnsCallableDelegate()
{
var builder = new Builder();
var app = builder.Build();
var mockHttpContext = new Moq.Mock<HttpContextBase>();
var mockHttpResponse = new Moq.Mock<HttpResponseBase>();
mockHttpContext.SetupGet(x => x.Response).Returns(mockHttpResponse.Object);
mockHttpResponse.SetupProperty(x => x.StatusCode);
app.Invoke(mockHttpContext.Object);
mockHttpContext.Object.Response.StatusCode.ShouldBe(404);
}
示例6: createMockPackage
/**
* Addition method to create a mock object
* */
private Package createMockPackage()
{
var dummyPackage = new Moq.Mock<Package>();
dummyPackage.SetupProperty(package => package.BarCode, 123456)
.SetupProperty(package => package.ExpiryDate, new DateTime(17, 12, 12));
return dummyPackage.Object;
}