当前位置: 首页>>代码示例>>C#>>正文


C# Moq.Mock.SetupProperty方法代码示例

本文整理汇总了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);
        }
开发者ID:EgoDust,项目名称:HttpAbstractions,代码行数:13,代码来源:ApplicationBuilderTests.cs

示例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"));
 }
开发者ID:hlim29,项目名称:ENET_Care_A1,代码行数:8,代码来源:UserTest.cs

示例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;
 }
开发者ID:hlim29,项目名称:ENET_Care_A1,代码行数:12,代码来源:StaffTest.cs

示例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;
 }
开发者ID:hlim29,项目名称:ENET_Care_A1,代码行数:13,代码来源:PackageTest.cs

示例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);
        }
开发者ID:niemyjski,项目名称:HttpAbstractions,代码行数:13,代码来源:BuilderTests.cs

示例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;
 }
开发者ID:hlim29,项目名称:ENET_Care_A1,代码行数:10,代码来源:AgentTest.cs


注:本文中的Moq.Mock.SetupProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。