Пример #1
0
 public async Task PutAsync_SerializesContent(
     [FrozenAsHttpClient] HttpClientSpy httpClientSpy,
     Uri uri, Model content, [Greedy] JSendClient client)
 {
     // Fixture setup
     var expectedContent = JsonConvert.SerializeObject(content);
     // Exercise system
     await client.PutAsync(uri, content);
     // Verify outcome
     var actualContent = httpClientSpy.Content;
     actualContent.Should().Be(expectedContent);
 }
 public async Task ParsesNakedData_AsASuccessResponse(Model model, HttpResponseMessage message,
     NakedContentParser parser)
 {
     // Fixture setup
     message.Content = new StringContent(JsonConvert.SerializeObject(model));
     // Exercise system
     var response = await parser.ParseAsync<Model>(null, message);
     // Verify outcome
     response.Status.Should().Be(JSendStatus.Success);
     response.Data.ShouldBeEquivalentTo(model);
 }
Пример #3
0
        public async Task PutAsync_ReturnsParsedResponse(
            HttpResponseMessage httpResponseMessage, JSendResponse<JToken> parsedResponse,
            [FrozenAsHttpClient] HttpClientStub httpClientStub,
            Uri uri, Model content, [Greedy] JSendClient client)
        {
            // Fixture setup
            httpClientStub.ReturnOnSend = httpResponseMessage;

            Mock.Get(client.Parser)
                .Setup(p => p.ParseAsync<JToken>(It.IsAny<JsonSerializerSettings>(), httpResponseMessage))
                .ReturnsAsync(parsedResponse);
            // Exercise system
            var response = await client.PutAsync(uri, content);
            // Verify outcome
            response.Should().BeSameAs(parsedResponse);
        }
 public async Task ParsesSuccessResponse_WithData(Model model, HttpResponseMessage message,
     DefaultJSendParser parser)
 {
     // Fixture setup
     message.Content = new StringContent(@"
     {
         ""status"": ""success"",
         ""data"": " + JsonConvert.SerializeObject(model) + @"
     }");
     // Exercise system
     var response = await parser.ParseAsync<Model>(null, message);
     // Verify outcome
     response.Status.Should().Be(JSendStatus.Success);
     response.Data.ShouldBeEquivalentTo(model);
 }