public void GetMessages_ReturnsInboxMessages() { // Arrange RestResource resource = new InboxMessagesResource(); var response = new RestResponse { StatusCode = HttpStatusCode.OK, Content = "serialisedItem" }; var expectedResult = new InboxMessageCollection(); mockRestClient .Setup(rc => rc.Get(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise<InboxMessageCollection>(response.Content)) .Returns(expectedResult); // Act var actualResult = service.GetMessages(); // Assert Assert.AreEqual(expectedResult, actualResult); }
public void GetMessages_ReturnsInboxMessages() { // Arrange RestResource resource = new InboxMessagesResource(); RestResponse response = new RestResponse() { StatusCode = HttpStatusCode.OK, Content = "serialisedItem" }; InboxMessageCollection expectedResult = new InboxMessageCollection(); mockRestClient .Setup(rc => rc.Get(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise <InboxMessageCollection>(response.Content)) .Returns(expectedResult); // Act InboxMessageCollection actualResult = service.GetMessages(); // Assert Assert.AreEqual(expectedResult, actualResult); }
public void InboxMessageCollection_DefaultDIConstructor() { // Arrange // Act var collection = new InboxMessageCollection(); // Assert Assert.That(collection.Messages, Is.InstanceOf<IEnumerable<InboxMessage>>()); }
public void InboxMessageCollection_DefaultDIConstructor() { // Arrange // Act var collection = new InboxMessageCollection(); // Assert Assert.That(collection.Messages, Is.InstanceOf <IEnumerable <InboxMessage> >()); }
public void InboxMessageCollection_SetPageNumber_WithNonZeroIndex_GetPageNumber_ReturnsPageNumber() { // Arrange var startIndex = 30; var pageSize = 15; var expectedPageNumber = 3; var collection = new InboxMessageCollection { PageSize = pageSize }; // Act collection.PageNumber = startIndex; // Assert Assert.AreEqual(expectedPageNumber, collection.PageNumber); }
public void InboxMessageCollection_SetPageNumber_WithZeroIndex_GetPageNumber_ReturnsPageNumber1() { // Arrange int startIndex = 0; int pageSize = 15; int expectedPageNumber = 1; InboxMessageCollection collection = new InboxMessageCollection() { PageSize = pageSize }; // Act collection.PageNumber = startIndex; // Assert Assert.AreEqual(expectedPageNumber, collection.PageNumber); }
public void InboxMessageCollection_SetPageNumber_WithNonZeroIndex_GetPageNumber_ReturnsPageNumber() { // Arrange var startIndex = 30; var pageSize = 15; var expectedPageNumber = 3; var collection = new InboxMessageCollection { PageSize = pageSize }; // Act collection.PageNumber = startIndex; // Assert Assert.AreEqual(expectedPageNumber, collection.PageNumber); }
public void InboxMessageCollection_SetPageNumber_WithZeroIndex_GetPageNumber_ReturnsPageNumber1() { // Arrange int startIndex = 0; int pageSize = 15; int expectedPageNumber = 1; InboxMessageCollection collection = new InboxMessageCollection() { PageSize = pageSize }; // Act collection.PageNumber = startIndex; // Assert Assert.AreEqual(expectedPageNumber, collection.PageNumber); }
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); } }
public void GetMessages_WithAccountReferenceAndPageNumberAndPageSize_ReturnsInboxMessages() { // Arrange string accountReference = "accountReference"; int pageNumber = 1; int pageSize = 15; RestResource resource = new InboxMessagesResource(accountReference, pageNumber, pageSize); RestResponse response = new RestResponse() { StatusCode = HttpStatusCode.OK, Content = "serialisedItem" }; InboxMessageCollection expectedResult = new InboxMessageCollection() { PageNumber = pageNumber, PageSize = pageSize }; mockRestClient .Setup(rc => rc.Get(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise <InboxMessageCollection>(response.Content)) .Returns(expectedResult); // Act InboxMessageCollection actualResult = service.GetMessages(accountReference, pageNumber, pageSize); // Assert Assert.AreEqual(expectedResult, actualResult); Assert.AreEqual(expectedResult.PageNumber, actualResult.PageNumber); Assert.AreEqual(expectedResult.PageSize, actualResult.PageSize); }
public void GetMessages_WithPageNumberAndPageSize_ReturnsInboxMessages() { // Arrange var pageNumber = 1; var pageSize = 15; RestResource resource = new InboxMessagesResource(pageNumber, pageSize); var response = new RestResponse { StatusCode = HttpStatusCode.OK, Content = "serialisedItem" }; var expectedResult = new InboxMessageCollection { PageNumber = pageNumber, PageSize = pageSize }; mockRestClient .Setup(rc => rc.Get(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise <InboxMessageCollection>(response.Content)) .Returns(expectedResult); // Act var actualResult = service.GetMessages(pageNumber, pageSize); // Assert Assert.AreEqual(expectedResult, actualResult); Assert.AreEqual(pageNumber, actualResult.PageNumber); Assert.AreEqual(pageSize, actualResult.PageSize); }
public void GetMessages_WithPageNumberAndPageSize_ReturnsInboxMessages() { // Arrange var pageNumber = 1; var pageSize = 15; RestResource resource = new InboxMessagesResource(pageNumber, pageSize); var response = new RestResponse { StatusCode = HttpStatusCode.OK, Content = "serialisedItem" }; var expectedResult = new InboxMessageCollection { PageNumber = pageNumber, PageSize = pageSize }; mockRestClient .Setup(rc => rc.Get(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise<InboxMessageCollection>(response.Content)) .Returns(expectedResult); // Act var actualResult = service.GetMessages(pageNumber, pageSize); // Assert Assert.AreEqual(expectedResult, actualResult); Assert.AreEqual(pageNumber, actualResult.PageNumber); Assert.AreEqual(pageSize, actualResult.PageSize); }
public void GetMessages_WithAccountReference_ReturnsInboxMessages() { // Arrange string accountReference = "accountReference"; RestResource resource = new InboxMessagesResource(accountReference); RestResponse response = new RestResponse() { StatusCode = HttpStatusCode.OK, Content = "serialisedItem" }; InboxMessageCollection expectedResult = new InboxMessageCollection(); mockRestClient .Setup(rc => rc.Get(resource)) .Returns(response); mockSerialiser .Setup(s => s.Deserialise<InboxMessageCollection>(response.Content)) .Returns(expectedResult); // Act InboxMessageCollection actualResult = service.GetMessages(accountReference); // Assert Assert.AreEqual(expectedResult, actualResult); }