public void GetMessages_WithPageNumberAndPageSize_ReturnsSentMessages()
        {
            // Arrange
            int pageNumber = 1;
            int pageSize   = 15;

            RestResource resource = new MessageHeadersResource(pageNumber, pageSize);

            RestResponse response = new RestResponse()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = "serialisedItem"
            };

            SentMessageCollection expectedResult = new SentMessageCollection()
            {
                PageNumber = pageNumber,
                PageSize   = pageSize,
            };

            mockRestClient
            .Setup(rc => rc.Get(resource))
            .Returns(response);

            mockSerialiser
            .Setup(s => s.Deserialise <SentMessageCollection>(response.Content))
            .Returns(expectedResult);

            // Act
            SentMessageCollection actualResult = service.GetMessages(pageNumber, pageSize);

            // Assert
            Assert.AreEqual(pageNumber, actualResult.PageNumber);
            Assert.AreEqual(pageSize, actualResult.PageSize);
        }
        private static void GetSentMessagesExample(EsendexCredentials credentials, MessageBodyService messageBodyService)
        {
            var sentService = new SentService(credentials);

            try
            {
                var collection = sentService.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);
            }
        }
Exemplo n.º 3
0
        private static void GetSentMessagesExample()
        {
            int pageNumber = 1;
            int pageSize   = 15;

            SentService sentService = new SentService(Credentials);

            try
            {
                SentMessageCollection collection = sentService.GetMessages(pageNumber, pageSize);

                foreach (SentMessage item in collection.Messages)
                {
                    Console.WriteLine("Message Id:{0}\nMessage:{1}\n\n", item.Id, item.Summary);
                }
            }
            catch (WebException ex)
            {
                Console.Write(ex.Message);
            }
        }
Exemplo n.º 4
0
 public SentMessageCollection GetMessages(int pageNumber, int pageSize)
 {
     return(_sentMessageService.GetMessages(_accountReference, pageNumber, pageSize));
 }