public void TestInitialize()
        {
            mockSerialiser = new Mock<ISerialiser>();
            mockRestClient = new Mock<IRestClient>();

            service = new ContactService(mockRestClient.Object, mockSerialiser.Object);
        }
        public void DefaultConstructor()
        {
            // Arrange
            var credentials = new EsendexCredentials("username", "password");

            // Act
            var serviceInstance = new ContactService(credentials);

            // Assert
            Assert.That(serviceInstance.RestClient, Is.InstanceOf<RestClient>());
            Assert.That(serviceInstance.Serialiser, Is.InstanceOf<XmlSerialiser>());
        }
        public void DefaultDIConstructor()
        {
            // Arrange
            var uri = new Uri("http://tempuri.org");
            var credentials = new EsendexCredentials("username", "password");
            IHttpRequestHelper httpRequestHelper = new HttpRequestHelper();
            IHttpResponseHelper httpResponseHelper = new HttpResponseHelper();
            IHttpClient httpClient = new HttpClient(credentials, uri, httpRequestHelper, httpResponseHelper);

            IRestClient restClient = new RestClient(httpClient);
            ISerialiser serialiser = new XmlSerialiser();

            // Act
            var serviceInstance = new ContactService(restClient, serialiser);

            // Assert
            Assert.That(serviceInstance.RestClient, Is.InstanceOf<RestClient>());
            Assert.That(serviceInstance.Serialiser, Is.InstanceOf<XmlSerialiser>());
        }
Exemplo n.º 4
0
        private static void GetContactsExample()
        {
            int pageNumber = 1;
            int pageSize = 15;

            ContactService contactService = new ContactService(Credentials);

            try
            {
                PagedContactCollection collection = contactService.GetContacts(pageNumber, pageSize);

                foreach (Contact item in collection.Contacts)
                {
                    Console.WriteLine("Contact Id:{0}\nQuickname:{1}\n\n", item.Id, item.QuickName);
                }
            }
            catch (WebException ex)
            {
                Console.Write(ex.Message);
            }
        }
Exemplo n.º 5
0
        private static void GetContactsExample(EsendexCredentials credentials)
        {
            var contactService = new ContactService(credentials);

            try
            {
                var collection = contactService.GetContacts(_accountReference, PageIndex, PageSize);

                foreach (var item in collection.Contacts)
                {
                    Console.WriteLine("\tContact Id:{0}\tQuickname:{1}", item.Id, item.QuickName);
                }
            }
            catch (WebException ex)
            {
                Console.Write(ex.Message);
            }
        }
        private static void AddContactToGroup(EsendexCredentials credentials)
        {
            var groupService = new GroupService(credentials);
            var contactService = new ContactService(credentials);

            try
            {
                var guid = new Guid("{YOUR Contact GUID}");
                var contact = contactService.GetContact(guid);
                groupService.AddContactToGroup(_accountReference, "{YOUR Group GUID}", contact);

            }
            catch (WebException ex)
            {
                Console.Write(ex.Message);
            }
        }
        public void TestInitialize()
        {
            mocks = new MockFactory(MockBehavior.Strict);

            mockSerialiser = mocks.Create<ISerialiser>();
            mockRestClient = mocks.Create<IRestClient>();

            service = new ContactService(mockRestClient.Object, mockSerialiser.Object);
        }