-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Null String being reported as String rather than JTokenType.Null (…
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Linq; | ||
using Newtonsoft.Json.Linq; | ||
#if DNXCORE50 | ||
using Xunit; | ||
using Test = Xunit.FactAttribute; | ||
using Assert = Newtonsoft.Json.Tests.XUnitAssert; | ||
using TestCase = Xunit.InlineDataAttribute; | ||
#else | ||
using NUnit.Framework; | ||
#endif | ||
|
||
namespace Newtonsoft.Json.Tests.Issues | ||
{ | ||
public class Issue2775 | ||
{ | ||
[Test] | ||
//https://github.com/JamesNK/Newtonsoft.Json/issues/2775 | ||
public void TokenType() | ||
{ | ||
var jObject = new JObject { { "NullProperty", false ? "0" : null } }; | ||
|
||
var jToken = JToken.FromObject(jObject); | ||
|
||
Assert.AreEqual(JTokenType.Null, jToken.Children().Children().Single().Type); | ||
|
||
jObject = new JObject { { "NullProperty", (string)null } }; | ||
|
||
jToken = JToken.FromObject(jObject); | ||
Assert.AreEqual(JTokenType.Null, jToken.Children().Children().Single().Type); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters