public void DeleteContact_Id_CorrectResult() { // SetUp Initialize(); var contact = ContactHelper.AddNewContact(); // Act accountController.DeleteContact(contact.Id); }
public void AddContact_NewContact_CorrectResult() { // SetUp Initialize(); var newContact = ContactHelper.AddNewContactViewModel(); // Act accountController.AddContact(newContact); var model = accountController.GetContact(0); // Assert Assert.NotNull(model); }
public void EditContact_Contact_CorrectResult() { // SetUp Initialize(); var newContact = ContactHelper.AddNewContactViewModel(); // Act var result = accountController.EditContact(newContact); var contactList = accountController.GetContacts(); // Assert Assert.AreEqual(typeof(OkResult), result.GetType()); Assert.NotNull(contactList.Value); }
private void Initialize() { var mock = new Mock <IContactRepository>(); mock.Setup(repo => repo.GetContacts()) .Returns(ContactHelper.GetTestContacts()); mock.Setup(repo => repo.GetContact(0)) .Returns(ContactHelper.AddNewContact()); mock.Setup(repo => repo.CheckAvailability(100)) .Returns(false); mock.Setup(repo => repo.CheckAvailability(0)) .Returns(true); contactManager = new ContactManager(mock.Object); }
private static void Initialize() { var moq = new Mock <IContactManager>(); moq.Setup(x => x.GetContacts()) .Returns( ContactHelper .GetTestContacts() .Select(ContactVM.FromModelToView) .ToList); moq.Setup(x => x.GetContactById(0)) .Returns(ContactVM .FromModelToView(ContactHelper.AddNewContact())); accountController = new AccountController(moq.Object); }