Skip to content

Commit 008dc3a

Browse files
committed
Merge with Newtonsoft.Json 8.0.3
1 parent 8f13660 commit 008dc3a

24 files changed

+866
-638
lines changed

src/Newtonsoft.Json.Tests/Converters/DiscriminatedUnionConverterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public void DeserializeBasicUnion_NoMatch()
252252
[Test]
253253
public void DeserializeBasicUnion_MismatchedFieldCount()
254254
{
255-
ExceptionAssert.Throws<JsonSerializationException>(() => JsonConvert.DeserializeObject<Currency>(@"{""Case"":""AUD"",""Fields"":[1]}"), "The number of field values does not match the number of properties definied by union 'AUD'. Path '', line 1, position 27.");
255+
ExceptionAssert.Throws<JsonSerializationException>(() => JsonConvert.DeserializeObject<Currency>(@"{""Case"":""AUD"",""Fields"":[1]}"), "The number of field values does not match the number of properties defined by union 'AUD'. Path '', line 1, position 27.");
256256
}
257257

258258
[Test]

src/Newtonsoft.Json.Tests/Converters/StringEnumConverterTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,28 @@ public class NegativeEnumClass
104104
public NegativeEnum Value2 { get; set; }
105105
}
106106

107+
[JsonConverter(typeof(StringEnumConverter), true)]
108+
public enum CamelCaseEnum
109+
{
110+
This,
111+
Is,
112+
CamelCase
113+
}
114+
115+
[Test]
116+
public void Serialize_CamelCaseFromAttribute()
117+
{
118+
string json = JsonConvert.SerializeObject(CamelCaseEnum.CamelCase);
119+
Assert.AreEqual(@"""camelCase""", json);
120+
}
121+
122+
[Test]
123+
public void Deserialize_CamelCaseFromAttribute()
124+
{
125+
CamelCaseEnum e = JsonConvert.DeserializeObject<CamelCaseEnum>(@"""camelCase""");
126+
Assert.AreEqual(CamelCaseEnum.CamelCase, e);
127+
}
128+
107129
#if !NET20
108130
[Test]
109131
public void NamedEnumDuplicateTest()

src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
using Newtonsoft.Json;
5050
using System.IO;
5151
using Newtonsoft.Json.Converters;
52+
using Newtonsoft.Json.Linq;
5253
using Newtonsoft.Json.Utilities;
5354

5455
namespace Newtonsoft.Json.Tests
@@ -136,6 +137,33 @@ public void BufferTest_WithError()
136137
Assert.AreEqual(1, arrayPool.FreeArrays.Count);
137138
}
138139

140+
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
141+
[Test]
142+
public void BufferErroringWithInvalidSize()
143+
{
144+
JObject o = new JObject
145+
{
146+
{"BodyHtml", "<h3>Title!</h3>" + Environment.NewLine + new string(' ', 100) + "<p>Content!</p>"}
147+
};
148+
149+
JsonArrayPool arrayPool = new JsonArrayPool();
150+
151+
StringWriter sw = new StringWriter();
152+
using (JsonTextWriter writer = new JsonTextWriter(sw))
153+
{
154+
writer.ArrayPool = arrayPool;
155+
156+
o.WriteTo(writer);
157+
}
158+
159+
string result = o.ToString();
160+
161+
Assert.AreEqual(@"{
162+
""BodyHtml"": ""<h3>Title!</h3>\r\n <p>Content!</p>""
163+
}", result);
164+
}
165+
#endif
166+
139167
[Test]
140168
public void NewLine()
141169
{
@@ -932,6 +960,7 @@ public void WriteTokenDirect_BadValue()
932960
#endif
933961
"Input string was not in a correct format.");
934962

963+
935964
ExceptionAssert.Throws<ArgumentNullException>(() => { jsonWriter.WriteToken(JsonToken.Integer); },
936965
#if UNITY3D
937966
@"Argument cannot be null.

0 commit comments

Comments
 (0)