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


C# MockFactory.VerifyAll方法代码示例

本文整理汇总了C#中MockFactory.VerifyAll方法的典型用法代码示例。如果您正苦于以下问题:C# MockFactory.VerifyAll方法的具体用法?C# MockFactory.VerifyAll怎么用?C# MockFactory.VerifyAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MockFactory的用法示例。


在下文中一共展示了MockFactory.VerifyAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: shouldCallSaveOnRepository

        public void shouldCallSaveOnRepository()
        {
            const string userName = "test";
            var password = "password";
            var factory = new MockFactory(MockBehavior.Strict);
            var mock = factory.Create<IUserBusinessLogic>();
            var userContextMock = new Mock<IUserContext>();

            mock.Setup(x => x.Create(It.Is<User>(y => y.Username == userName))).Returns(new User());

            var controller = new CarbonFitness.App.Web.Controllers.UserController(mock.Object, userContextMock.Object);
            controller.Create(userName, password);
            factory.VerifyAll();
        }
开发者ID:yodiz,项目名称:CarbonFitness,代码行数:14,代码来源:CreateTest.cs

示例2: shouldImportIngredients

        public void shouldImportIngredients()
        {
            var factory = new MockFactory(MockBehavior.Strict);
            var ingredientParserMock = factory.Create<IIngredientParser>();
            var ingredientFileReaderMock = factory.Create<IIngredientFileReader>();
            var ingredientRepositoryMock = factory.Create<IIngredientRepository>();

            const string abc = "abc";
            const string fileName = "fileName";
            ingredientFileReaderMock.Setup(x => x.ReadIngredientFile(fileName)).Returns(abc);
            const string abborre = "Abborre";
            ingredientParserMock.Setup(x => x.CreateIngredientFromFileContents(abc)).Returns(new List<Ingredient> {new Ingredient {Name = abborre}});
            ingredientRepositoryMock
                .Setup(x => x.SaveOrUpdate(It.Is<Ingredient>(y => y.Name == abborre)))
                .Returns(null as Ingredient);

            new IngredientImporter(ingredientParserMock.Object, ingredientFileReaderMock.Object, ingredientRepositoryMock.Object)
                .Import(fileName);

            factory.VerifyAll();
        }
开发者ID:yodiz,项目名称:CarbonFitness,代码行数:21,代码来源:IngredientImporterTest.cs

示例3: TestPersistWithFactory

        public void TestPersistWithFactory()
        {
            MockFactory factory = new MockFactory(MockBehavior.Strict);

            //Classes work, methods have to be virtual -> not nice
            var mockGateway = factory.Create<UserGateway>();
            var mockValidator = factory.Create<IUserValidator>();

            User user = new User();

            //Excpectations
            mockValidator.Setup(x => x.Validate(user)).Returns(true).AtMostOnce();
            mockGateway.Setup(x => x.Persist(user)).Returns(true).AtMostOnce();

            //Assign gateway
            user.Gateway = mockGateway.Object;

            //Test method
            Assert.AreEqual(true, user.Persist(mockValidator.Object));

            factory.VerifyAll();
        }
开发者ID:pweibel,项目名称:DotNetMockingFrameworksDemo,代码行数:22,代码来源:MoqTest.cs

示例4: AssertUserIngredientsExist

 private void AssertUserIngredientsExist(MockFactory mockFactory, InputFoodModel model)
 {
     Assert.That(model.UserIngredients, Is.Not.Null);
     Assert.That(model.UserIngredients.Count(), Is.EqualTo(2));
     Assert.That(model.UserIngredients.First().Date.ToShortDateString(), Is.EqualTo(DateTime.Now.ToShortDateString()));
     mockFactory.VerifyAll();
 }
开发者ID:yodiz,项目名称:CarbonFitness,代码行数:7,代码来源:InputTest.cs


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