Permalink
Browse files

Fixed json line ending trimming

  • Loading branch information...
1 parent 2ed7a04 commit c26ee3b5edc654bab4ee825afc83503faff7e388 @thecodejunkie thecodejunkie committed Oct 3, 2012
@@ -13,6 +13,7 @@ namespace Nancy.Tests.Unit.ModelBinding.DefaultBodyDeserializers
using Nancy.ModelBinding.DefaultBodyDeserializers;
using Xunit;
+ using Xunit.Extensions;
public class JsonBodyDeserializerFixture
{
@@ -248,11 +249,15 @@ public void Should_Serialize_Doubles_In_Different_Cultures()
#endif
- [Fact]
- public void Should_Serialize_Last_Prop_is_Bool_And_Trailing_NewLine()
+ [Theory]
+ [InlineData("\n")]
+ [InlineData("\n\r")]
+ [InlineData("\r\n")]
+ [InlineData("\r")]
+ public void Should_Serialize_Last_Prop_is_Bool_And_Trailing_NewLine(string lineEndings)
{
// Given
- var json = "{\"Property\": true\r\n}";
+ var json = string.Concat("{\"Property\": true", lineEndings, "}");
// When
var s = new JavaScriptSerializer();
@@ -495,7 +495,7 @@ bool ParseBuffer (out object result)
if (jsonType != JsonType.STRING)
{
- s = s.TrimEnd(Environment.NewLine.ToCharArray());
+ s = s.TrimEnd(new[] { '\n', '\r' });
}
switch (jsonType) {

0 comments on commit c26ee3b

Please sign in to comment.