public void Initialize() { _phonebookServiceMock = new Mock <IPhoneBookService>(); _phonebookTypeServiceMock = new Mock <IPhoneBookTypeService>(); _phonebookEntryServiceMock = new Mock <IPhoneBookEntryService>(); _phoneBookController = new PhonebookTestController(_phonebookServiceMock.Object, _phonebookEntryServiceMock.Object, _phonebookTypeServiceMock.Object); _phoneBookApiController = new PhonebookApiController(_phonebookServiceMock.Object, _phonebookEntryServiceMock.Object, _phonebookTypeServiceMock.Object); listPhoneTypes = new List <PhoneBookType>() { new PhoneBookType() { Id = 1, Description = "Home" }, new PhoneBookType() { Id = 2, Description = "Work" }, new PhoneBookType() { Id = 3, Description = "Cell" } }; listNumbers = new List <PhoneNumberEditorViewModel>() { new PhoneNumberEditorViewModel() { PhoneBookTypeId = "1", Number = "0216657874" }, new PhoneNumberEditorViewModel() { PhoneBookTypeId = "2", Number = "0214563214" }, new PhoneNumberEditorViewModel() { PhoneBookTypeId = "3", Number = "0815400171" } }; }
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"]); }