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 LoadBodyText_UpdatesMessageBodyWithBodyText() { const string expectedMessageBody = "This is the body of the message"; var id = Guid.NewGuid(); var messageBody = new MessageBody { Id = id, Uri = string.Format("https://api.esendex.com/v1.0/messageheaders/{0}/body", id), BodyText = string.Empty }; mockRestClient .Setup(c => c.Get(It.IsAny <ResourceLinkResource>())) .Returns(new RestResponse()); mockSerialiser .Setup(s => s.Deserialise <MessageBody>(It.IsAny <string>())) .Returns(new MessageBody { BodyText = expectedMessageBody }); service.LoadBodyText(messageBody); Assert.That(messageBody.BodyText, Is.EqualTo(expectedMessageBody)); }