public void GetMessage_WithId_ReturnsSentMessage()
        {
            // Arrange
            var id = Guid.NewGuid();

            RestResource resource = new MessageHeadersResource(id);

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

            var expectedResult = new SentMessage();

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

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

            // Act
            var actualResult = service.GetMessage(id);

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            MessageHeadersResource other = obj as MessageHeadersResource;

            if (other == null)
            {
                return(false);
            }

            return(base.Equals(obj));
        }
        public void DefaultConstructor_WithId()
        {
            // Arrange
            var id = Guid.NewGuid();
            var expectedResourcePath = string.Format("messageheaders/{0}", id);

            // Act
            RestResource resource = new MessageHeadersResource(id);

            // Assert
            Assert.AreEqual(expectedResourcePath, resource.ResourcePath);
        }
        public void DefaultConstructor_WithPageNumber2AndPageSize()
        {
            // Arrange
            var pageNumber = 2;
            var pageSize = 15;

            var expectedResourcePath = string.Format("messageheaders?startIndex=15&count={0}", pageSize);

            // Act
            RestResource resource = new MessageHeadersResource(pageNumber, pageSize);

            // Assert
            Assert.AreEqual(expectedResourcePath, resource.ResourcePath);
        }
        public void DefaultConstructor_WithInvalidPageNumberAndPageSize()
        {
            // Arrange
            var pageNumber = 0;
            var pageSize = 0;

            // Act
            try
            {
                RestResource resource = new MessageHeadersResource(pageNumber, pageSize);

                Assert.Fail();
            }
                // Assert
            catch (ArgumentException ex)
            {
                Assert.AreEqual("pageNumber", ex.ParamName);
            }
        }
        public void DefaultConstructor_WithNullAccountReference()
        {
            // Arrange
            int pageNumber = 1;
            int pageSize = 15;
            string accountReference = null;

            // Act
            try
            {
                RestResource resource = new MessageHeadersResource(accountReference, pageNumber, pageSize);

                Assert.Fail();
            }
            // Assert
            catch (ArgumentException ex)
            {
                Assert.AreEqual("accountReference", ex.ParamName);
            }
        }
        public void GetMessages_WithPageNumberAndPageSizeAndAccountReference_ReturnsSentMessages()
        {
            // Arrange
            int pageNumber = 1;
            int pageSize = 15;
            string accountReference = "accountReference";

            RestResource resource = new MessageHeadersResource(accountReference, 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(accountReference, pageNumber, pageSize);

            // Assert
            Assert.AreEqual(pageNumber, actualResult.PageNumber);
            Assert.AreEqual(pageSize, actualResult.PageSize);
        }
        public void GetMessages_WithPageNumberAndPageSize_ReturnsSentMessages()
        {
            // Arrange
            var pageNumber = 1;
            var pageSize = 15;

            RestResource resource = new MessageHeadersResource(pageNumber, pageSize);

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

            var 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
            var actualResult = service.GetMessages(pageNumber, pageSize);

            // Assert
            Assert.AreEqual(pageNumber, actualResult.PageNumber);
            Assert.AreEqual(pageSize, actualResult.PageSize);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets a com.esendex.sdk.inbox.InboxMessage instance containing an inbox message.
        /// </summary>
        /// <param name="id">A System.Guid instance that contains the Id of an inbox message.</param>
        /// <returns>A com.esendex.sdk.inbox.InboxMessage instance containing an inbox message.</returns>
        /// <exception cref="System.Net.WebException"></exception>
        public InboxMessage GetMessage(Guid id)
        {
            RestResource resource = new MessageHeadersResource(id);

            return MakeRequest<InboxMessage>(HttpMethod.GET, resource);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets a com.esendex.sdk.sent.SentMessageCollection instance containing sent messages.
        /// </summary>
        /// <param name="accountReference">A System.String instance that contains the account reference.</param>
        /// <param name="pageNumber">The number of the page.</param>
        /// <param name="pageSize">The number of messages in the page.</param>
        /// <returns>A com.esendex.sdk.sent.SentMessageCollection instance that contains the sent messages.</returns>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.Net.WebException"></exception>
        public SentMessageCollection GetMessages(string accountReference, int pageNumber, int pageSize)
        {
            RestResource resource = new MessageHeadersResource(accountReference, pageNumber, pageSize);

            return MakeRequest<SentMessageCollection>(HttpMethod.GET, resource);
        }
        public void DefaultConstructor_WithPageNumberAndPageSizeAndAccountReference()
        {
            // Arrange
            var pageNumber = 1;
            var pageSize = 15;
            var accountReference = "accountReference";

            var expectedResourcePath =
                string.Format("messageheaders?startIndex=0&count={0}&filterBy=account&filterValue={1}",
                              pageSize, accountReference);

            // Act
            RestResource resource = new MessageHeadersResource(accountReference, pageNumber, pageSize);

            // Assert
            Assert.AreEqual(expectedResourcePath, resource.ResourcePath);
        }