コード例 #1
0
        public void GetContact_ThrowsException_InvalidId()
        {
            var moqContactsRepository = new Mock <IContactsRepository>();
            var service = new ContactsService(moqContactsRepository.Object);

            moqContactsRepository.Setup(r => r.GetContact(0)).Throws <Exception>();

            Assert.That(() => service.GetContact(0), Throws.Exception);
        }
コード例 #2
0
        public void test_fetching_contacts()
        {
            var service = new ContactsService(_gateway);

            var filter = new ContactsFilter
            {
                PageSize   = 1,
                PageNumber = 1,
                //LastUpdatedFilter = new DateTimeOffset(new DateTime(2018, 1, 1), TimeSpan.FromMinutes(120)),
                TypeFilter  = ContactType.Company,
                EmailFilter = "aplos",
                NameFilter  = "software"
            };

            var contacts = service.GetContacts(filter);

            contacts.Data.Contacts.Count.Should().BeGreaterThan(0);

            var contact = service.GetContact(contacts.Data.Contacts[0].Id);
        }
コード例 #3
0
        public async Task <bool> InitializeAsync()
        {
            if (IsNew)
            {
                ActionText = "Add";
            }
            else
            {
                using (UserDialogs.Instance.Loading("Loading"))
                {
                    var contact = await ContactsService.GetContact(ContactId);

                    _isNew     = false;
                    Id         = contact.Id;
                    Name       = contact.Name;
                    Company    = contact.Company;
                    ActionText = "Save";
                }
            }

            return(true);
        }
コード例 #4
0
        public IActionResult GetContact(int contactId)
        {
            Contact contact = _contactsService.GetContact(contactId);

            return(Ok(new { contact }));
        }