public void ThrowArgumentNullException_WhenParserUserViewModelParameterIsNull() { // Arrange var parserUserDataProvider = new Mock <IParserUserDataProvider>(); var entityFrameworkTransactionFactory = new Mock <IEntityFrameworkTransactionFactory>(); var createParserUserService = new CreateParserUserService(parserUserDataProvider.Object, entityFrameworkTransactionFactory.Object); ParserUserViewModel model = null; // Act & Assert Assert.That( () => createParserUserService.CreateParserUser(model), Throws.InstanceOf <ArgumentNullException>().With.Message.Contains(nameof(ParserUserViewModel))); }
public void ReturnCorrectParserUserViewModelInstance() { // Arrange var parserUserDataProvider = new Mock <IParserUserDataProvider>(); var entityFrameworkTransactionFactory = new Mock <IEntityFrameworkTransactionFactory>(); var transaction = new Mock <IEntityFrameworkTransaction>(); entityFrameworkTransactionFactory.Setup(f => f.CreateEntityFrameworkTransaction()).Returns(transaction.Object); var createParserUserService = new CreateParserUserService(parserUserDataProvider.Object, entityFrameworkTransactionFactory.Object); var model = new ParserUserViewModel(); // Act var actualReturnedParserUserViewModelInstance = createParserUserService.CreateParserUser(model); // Assert Assert.That(actualReturnedParserUserViewModelInstance, Is.SameAs(model)); }
public void InvokeIEntityFrameworkTransaction_SaveChangesMethodOnce() { // Arrange var parserUserDataProvider = new Mock <IParserUserDataProvider>(); var entityFrameworkTransactionFactory = new Mock <IEntityFrameworkTransactionFactory>(); var transaction = new Mock <IEntityFrameworkTransaction>(); entityFrameworkTransactionFactory.Setup(f => f.CreateEntityFrameworkTransaction()).Returns(transaction.Object); var createParserUserService = new CreateParserUserService(parserUserDataProvider.Object, entityFrameworkTransactionFactory.Object); var model = new ParserUserViewModel(); // Act createParserUserService.CreateParserUser(model); // Assert transaction.Verify(t => t.SaveChanges(), Times.Once); }