本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}