Пример #1
0
        public async void GetAsync_Called_ReturnsResponse()
        {
            // Given
            var client   = new Mock <IRestClient>();
            var response = new SatisfactionRatingResponse {
                Item = new SatisfactionRating {
                    Id = 1
                }
            };

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

            client.Setup(b => b.BuildUri(It.IsAny <string>(), It.Is <string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk"));
            var resource = new SatisfactionRatingResource(client.Object);

            // When
            var result = await resource.GetAsync(321);

            // Then
            Assert.Equal(result, response);
        }
        public async void GetAsync_Called_CallsBuildUriWithFieldId()
        {
            // Given
            _client.Setup(b => b.BuildUri(It.IsAny <string>(), It.Is <string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk"));
            var resource = new SatisfactionRatingResource(_client.Object);

            // When
            await resource.GetAsync(321);

            // Then
            _client.Verify(c => c.BuildUri(It.Is <string>(s => s.Contains("/satisfaction_ratings/321")), ""));
        }
        public async void GetAsync_Called_CallsBuildUriWithFieldId()
        {
            // Given
            _client.Setup(b => b.BuildUri(It.IsAny<string>(), It.Is<string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk"));
            var resource = new SatisfactionRatingResource(_client.Object);

            // When
            await resource.GetAsync(321);

            // Then
            _client.Verify(c => c.BuildUri(It.Is<string>(s => s.Contains("/satisfaction_ratings/321")), ""));
        }
        public async void GetAsync_Called_ReturnsResponse()
        {
            // Given
            var response = new SatisfactionRatingResponse { Item = new SatisfactionRating { Id = 1 }};
            _client.Setup(b => b.GetAsync<SatisfactionRatingResponse>(
                It.IsAny<Uri>(),
                It.IsAny<string>(),
                It.IsAny<string>()))
                .Returns(TaskHelper.CreateTaskFromResult(response));

            _client.Setup(b => b.BuildUri(It.IsAny<string>(), It.Is<string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk"));
            var resource = new SatisfactionRatingResource(_client.Object);

            // When
            var result = await resource.GetAsync(321);

            // Then
            Assert.That(result, Is.EqualTo(response));
        }