public void InvokeSaveChangesOnDbContext() { var model = new ContactEditModel { FirstName = "Han", LastName = "Solo" }; var contactsController = new ContactsController(_mockDbContext.Object); var result = contactsController.Post(model).Result; _mockDbContext.Verify(x => x.SaveChangesAsync(), Times.Exactly(1)); }
public void AddNewContactToTheDbContext() { var model = new ContactEditModel { FirstName = "Han", LastName = "Solo" }; var contactsController = new ContactsController(_mockDbContext.Object); var result = contactsController.Post(model).Result; _mockDbContext.MockContactsDbSet.Verify(x => x.Add(It.IsAny<Contact>()), Times.Exactly(1)); }