public void ThrowsWhenResponse_IsNotValidJson(HttpResponseMessage message, NakedContentParser parser)
 {
     // Fixture setup
     message.Content = new StringContent("1,2,3");
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync <Model>(null, message))
     .ShouldThrow <JSendParseException>()
     .WithInnerException <JsonReaderException>();
 }
 public void ThrowsWhenResponseHasEmptyBody(string content, HttpResponseMessage message, NakedContentParser parser)
 {
     // Fixture setup
     message.Content = new StringContent(content);
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync <Model>(null, message))
     .ShouldThrow <JSendParseException>()
     .WithMessage(StringResources.ResponseWithEmptyBody);
 }
 public void ThrowsWhenResponse_IsNotValidJson(HttpResponseMessage message, NakedContentParser parser)
 {
     // Fixture setup
     message.Content = new StringContent("1,2,3");
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync<Model>(null, message))
         .ShouldThrow<JSendParseException>()
         .WithInnerException<JsonReaderException>();
 }
 public void ThrowsWhenResponseHasNoContent(HttpResponseMessage message, NakedContentParser parser)
 {
     // Fixture setup
     message.Content = null;
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync<Model>(null, message))
         .ShouldThrow<JSendParseException>()
         .WithMessage(StringResources.ResponseWithoutContent);
 }
 public void ThrowsWhenNakedDataIsOfAWrongType(HttpResponseMessage message, NakedContentParser parser)
 {
     // Fixture setup
     message.Content = new StringContent("\"invalid data\"");
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync <Model>(null, message))
     .ShouldThrow <JSendParseException>()
     .WithInnerException <JsonSerializationException>()
     .WithInnerMessage("Error converting value \"invalid data\"*");
 }
        public void WrapsJsonExeptionsWithCorrectMessage(HttpResponseMessage message, NakedContentParser parser)
        {
            // Fixture setup
            const string invalidContent = "qwerty";

            var expectedMessage =
                @"HTTP response message could not be parsed into an instance of type ""JSend.Client.JSendResponse`1[JSend.Client.Tests.TestTypes.Model]"". Content:" +
                Environment.NewLine +
                invalidContent;

            message.Content = new StringContent(invalidContent);
            // Exercise system and verify outcome
            parser.Awaiting(p => p.ParseAsync <Model>(null, message))
            .ShouldThrow <JSendParseException>()
            .WithMessage(expectedMessage)
            .WithInnerException <JsonException>();
        }
        public void WrapsJsonExeptionsWithCorrectMessage(HttpResponseMessage message, NakedContentParser parser)
        {
            // Fixture setup
            const string invalidContent = "qwerty";

            var expectedMessage =
                @"HTTP response message could not be parsed into an instance of type ""JSend.Client.JSendResponse`1[JSend.Client.Tests.TestTypes.Model]"". Content:" +
                Environment.NewLine +
                invalidContent;

            message.Content = new StringContent(invalidContent);
            // Exercise system and verify outcome
            parser.Awaiting(p => p.ParseAsync<Model>(null, message))
                .ShouldThrow<JSendParseException>()
                .WithMessage(expectedMessage)
                .WithInnerException<JsonException>();
        }
 public void ThrowsWhenHttpResponseMessageIsNull(NakedContentParser parser)
 {
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync <Model>(null, null))
     .ShouldThrow <ArgumentNullException>();
 }
 public void ThrowsWhenHttpResponseMessageIsNull(NakedContentParser parser)
 {
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync<Model>(null, null))
         .ShouldThrow<ArgumentNullException>();
 }
 public void ThrowsWhenNakedDataIsOfAWrongType(HttpResponseMessage message, NakedContentParser parser)
 {
     // Fixture setup
     message.Content = new StringContent("\"invalid data\"");
     // Exercise system and verify outcome
     parser.Awaiting(p => p.ParseAsync<Model>(null, message))
         .ShouldThrow<JSendParseException>()
         .WithInnerException<JsonSerializationException>()
         .WithInnerMessage("Error converting value \"invalid data\"*");
 }