Exemplo n.º 1
0
        public void DeleteContact_Id_CorrectResult()
        {
            // SetUp
            Initialize();
            var contact = ContactHelper.AddNewContact();

            // Act
            accountController.DeleteContact(contact.Id);
        }
Exemplo n.º 2
0
        public void AddContact_NewContact_CorrectResult()
        {
            // SetUp
            Initialize();
            var newContact = ContactHelper.AddNewContactViewModel();

            // Act
            accountController.AddContact(newContact);
            var model = accountController.GetContact(0);

            // Assert
            Assert.NotNull(model);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }