public async void GetAllAsync_CalledWithId_ReturnsListOfComments()
        {
            //Given
            var client   = new Mock <IRestClient>();
            var response = new TicketCommentListResponse
            {
                Results = new List <TicketComment> {
                    new TicketComment {
                        Id = 123
                    }
                }
            };

            client.Setup(c => c.GetAsync <TicketCommentListResponse>(
                             It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(TaskHelper.CreateTaskFromResult(response));

            var resource = new TicketCommentResource(client.Object);

            //When
            var result = await resource.GetAllAsync(123);

            //Then
            Assert.Equal(result, response);
        }
Beispiel #2
0
        public async void GetAllAsync_Called_UrlIsCorrect()
        {
            //Given
            var response = new TicketCommentListResponse();

            _client.Setup(c => c.GetAsync <TicketCommentListResponse>(It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <string>())).Returns(TaskHelper.CreateTaskFromResult(response));
            var resource = new TicketCommentResource(_client.Object);

            //When
            await resource.GetAllAsync(123);

            //Then
            _client.Verify(c => c.BuildUri(It.Is <string>(u => u.Contains("tickets/123/comments")), It.IsAny <string>()));
        }
        public async void GetAllAsync_CalledWithId_ReturnsListOfComments()
        {
            //Given
            var response = new TicketCommentListResponse
            {
                Results = new List<TicketComment> { new TicketComment { Id = 123 } }
            };
            _client.Setup(c => c.GetAsync<TicketCommentListResponse>(
                It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<string>()))
                .Returns(TaskHelper.CreateTaskFromResult(response));

            var resource = new TicketCommentResource(_client.Object);

            //When
            var result = await resource.GetAllAsync(123);

            //Then
            Assert.That(result, Is.EqualTo(response));
        }
        public async void GetAllAsync_Called_UrlIsCorrect()
        {
            //Given
            var response = new TicketCommentListResponse();
            _client.Setup(c => c.GetAsync<TicketCommentListResponse>(It.IsAny<Uri>(), It.IsAny<string>(), It.IsAny<string>())).Returns(TaskHelper.CreateTaskFromResult(response));
            var resource = new TicketCommentResource(_client.Object);

            //When
            await resource.GetAllAsync(123);

            //Then
            _client.Verify(c => c.BuildUri(It.Is<string>(u => u.Contains("tickets/123/comments")), It.IsAny<string>()));
        }