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

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

            // Act
            var serviceInstance = new InboxService(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 InboxService(restClient, serialiser);

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

            InboxService inboxService = new InboxService(Credentials);

            try
            {
                InboxMessageCollection collection = inboxService.GetMessages(pageNumber, pageSize);

                foreach (InboxMessage item in collection.Messages)
                {
                    Console.WriteLine("Message Id:{0}\nMessage:{1}\n\n", item.Id, item.Summary);
                }

            }
            catch (WebException ex)
            {
                Console.Write(ex.Message);
            }
        }
Esempio n. 5
0
        private static void GetInboxMessagesExample(EsendexCredentials credentials, MessageBodyService messageBodyService)
        {
            var inboxService = new InboxService(credentials);

            try
            {
                var collection = inboxService.GetMessages(_accountReference, PageIndex, PageSize);

                foreach (var item in collection.Messages)
                {
                    if (messageBodyService != null)
                    {
                        messageBodyService.LoadBodyText(item.Body);
                        Console.WriteLine("\tMessage Id:{0}\tSummary:{1}\n\tBody:{2}\n",
                                          item.Id,
                                          item.Summary,
                                          item.Body.BodyText);
                    }
                    else
                    {
                        Console.WriteLine("\tMessage Id:{0}\tSummary:{1}",
                                          item.Id,
                                          item.Summary);
                    }
                }
            }
            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 InboxService(mockRestClient.Object, mockSerialiser.Object);
        }