public void Get_Called_ReturnsResponse()
        {
            // Given
            var response = new SatisfactionRatingResponse {
                Item = new SatisfactionRating {
                    Id = 1
                }
            };

            _client.Setup(b => b.Get <SatisfactionRatingResponse>(
                              It.IsAny <Uri>(),
                              It.IsAny <string>(),
                              It.IsAny <string>()))
            .Returns(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 = resource.Get(321);

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

            //check the resource and operation are correctly populated
            _client.Verify(c => c.Get <SatisfactionRatingResponse>(
                               It.IsAny <Uri>(),
                               It.Is <string>(s => s == "SatisfactionRatingResource"),
                               It.Is <string>(s => s == "Get")));
        }
コード例 #2
0
        public void Get_Called_ReturnsResponse()
        {
            // Given
            var response = new SatisfactionRatingResponse { Item = new SatisfactionRating { Id = 1 }};
            _client.Setup(b => b.Get<SatisfactionRatingResponse>(
                It.IsAny<Uri>(),
                It.IsAny<string>(),
                It.IsAny<string>()))
                .Returns(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 = resource.Get(321);

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

            //check the resource and operation are correctly populated
            _client.Verify(c => c.Get<SatisfactionRatingResponse>(
                It.IsAny<Uri>(),
                It.Is<string>(s => s == "SatisfactionRatingResource"),
                It.Is<string>(s => s == "Get")));
        }
        public void Get_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
            resource.Get(321);

            // Then
            _client.Verify(c => c.BuildUri(It.Is <string>(s => s.Contains("/satisfaction_ratings/321")), ""));
        }
コード例 #4
0
        public void Get_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
            resource.Get(321);

            // Then
            _client.Verify(c => c.BuildUri(It.Is<string>(s => s.Contains("/satisfaction_ratings/321")), ""));
        }
        public void Post_MultipleMethodsAreCalled_CalledUrlIsCorrect()
        {
            // 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
            resource.Get(321);
            resource.Post(new SatisfactionRatingRequest(), 1);

            // Then
            _client.Verify(c => c.BuildUri(It.Is <string>(s => s.Contains("/tickets/1")), ""));
        }
コード例 #6
0
        public void Post_MultipleMethodsAreCalled_CalledUrlIsCorrect()
        {
            // 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
            resource.Get(321);
            resource.Post(new SatisfactionRatingRequest(), 1);

            // Then
            _client.Verify(c => c.BuildUri(It.Is<string>(s => s.Contains("/tickets/1")), ""));
        }