Ejemplo n.º 1
0
        public void GetUsers_ValidUsers_RaiseException()
        {
            var mockUsers = ContactMockData.GetMockUsers(mockRepository, 5).ToList();

            mockContactRepository.Setup(c => c.GetUsers(ACCOUNT_ID, OWNER_ID, false)).Throws(new NullReferenceException());

            GetUsersResponse response = contactService.GetUsers(new GetUsersRequest()
            {
                AccountID = ACCOUNT_ID, UserId = USER_ID
            });

            mockRepository.VerifyAll();
            Assert.AreEqual(typeof(NullReferenceException), response.Exception.GetType());
            Assert.AreNotEqual(null, response.Exception);
        }
Ejemplo n.º 2
0
        public void GetPerson_ValidContact_Succeed()
        {
            var mockContact = ContactMockData.GetMockPersonsWithSetups(mockRepository, 1).FirstOrDefault();

            mockContactRepository.Setup(cr => cr.FindBy(It.IsAny <int>())).Returns(mockContact.Object);
            mockTagRepository.Setup(c => c.FindByContact(It.IsAny <int>(), It.IsAny <int>())).Returns(new List <Tag>());

            GetPersonResponse response = contactService.GetPerson(new GetPersonRequest(1));
            int id = response.PersonViewModel.ContactID;

            mockRepository.VerifyAll();
            mockTagRepository.VerifyAll();
            Assert.AreEqual(mockContact.Object.Id, id);
            Assert.AreEqual(null, response.Exception);
        }
Ejemplo n.º 3
0
        public void GetUsers_ValidUsers_Succeed()
        {
            var mockUsers = ContactMockData.GetMockUsers(mockRepository, 5).ToList();

            mockContactRepository.Setup(c => c.GetUsers(ACCOUNT_ID, OWNER_ID, false)).Returns(mockUsers);

            GetUsersResponse response = contactService.GetUsers(new GetUsersRequest()
            {
                AccountID = ACCOUNT_ID, UserId = USER_ID
            });
            var users = response.Owner;

            mockRepository.VerifyAll();
            Assert.AreEqual(mockUsers.Count, users.Count());
            Assert.AreEqual(null, response.Exception);
        }
Ejemplo n.º 4
0
        public void GetAllContacts_ValidPersonsAndCompanies_Succeed()
        {
            var mockContacts = ContactMockData.GetMockContacts(mockRepository, 10).ToList();

            mockContactRepository.Setup(cr => cr.FindAll(It.IsAny <string>())).Returns(mockContacts);
            //mockSearchService.Setup(c => c.Search("Adam", new SearchParameters() { AutoCompleteFieldName = "Adam"})).Returns();

            SearchContactsResponse <ContactListEntry> response = contactService.GetAllContacts <ContactListEntry>(new SearchContactsRequest()
            {
                Query = ""
            });
            var contacts = response.Contacts;

            mockRepository.VerifyAll();
            Assert.AreEqual(mockContacts.Count, contacts.Count());
            Assert.AreEqual(null, response.Exception);
        }