public void Invalid_Contact_Create() { _phoneBookController.ModelState.AddModelError("Error", "Something went wrong when trynig to save contact to Phonebook!"); _phonebookEditViewModel = new PhonebookEditViewModel { FirstName = "", LastName = "", Numbers = null }; var result = (ViewResult)_phoneBookController.Save(_phonebookEditViewModel); _phonebookServiceMock.Verify(m => m.Create(new PhoneBook()), Times.Never); Assert.AreEqual("", result.ViewName); }
public void Valid_Contact_Create() { _phoneBookController = new PhonebookTestController(); var contact = new PhoneBook() { Name = "Alwyn", Surname = "Underwood", CreatedDate = DateTime.Now }; _phonebookEditViewModel = new PhonebookEditViewModel { FirstName = contact.Name, LastName = contact.Surname, Numbers = listNumbers }; var result = (RedirectToRouteResult)_phoneBookController.Save(_phonebookEditViewModel); _phonebookServiceMock.Verify(m => m.Create(contact), Times.Once); Assert.AreEqual("Index", result.RouteValues["action"]); }