-Formatting
-Build
This commit is contained in:
@@ -17,6 +17,7 @@ using TestAttribute = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Linq
|
||||
@@ -173,7 +174,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.AreEqual(null, s);
|
||||
|
||||
o.AddAnnotation("A string 4!");
|
||||
|
||||
|
||||
s = o.Annotation<string>();
|
||||
Assert.AreEqual("A string 4!", s);
|
||||
|
||||
@@ -277,7 +278,6 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
o["age"] = 59;
|
||||
o["employer"] = "Bill & Melinda Gates Foundation";
|
||||
|
||||
|
||||
HashSet<string> changedProperties = o.Annotation<HashSet<string>>();
|
||||
// age
|
||||
// employer
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
foreach (dynamic friend in o.friends)
|
||||
{
|
||||
UpdateValueCount(counts, friend.id);
|
||||
UpdateValueCount(counts, ((string) friend.name).Split(' ')[0]);
|
||||
UpdateValueCount(counts, ((string)friend.name).Split(' ')[0]);
|
||||
}
|
||||
|
||||
count++;
|
||||
@@ -863,7 +863,6 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
string oldRole = (string)oldAndBusted["Roles"][0];
|
||||
// Admin
|
||||
|
||||
|
||||
dynamic newHotness = new JObject();
|
||||
newHotness.Name = "Arnie Admin";
|
||||
newHotness.Enabled = true;
|
||||
|
||||
@@ -435,7 +435,6 @@ Parameter name: index");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void ITypedListGetItemProperties()
|
||||
|
||||
@@ -97,7 +97,9 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
roles.Add(role);
|
||||
|
||||
if (!reader.Read())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.AreEqual(2, roles.Count);
|
||||
@@ -121,7 +123,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
|
||||
JToken o = JToken.Parse(json);
|
||||
|
||||
Assert.AreEqual("Apple", (string) o["Name"]);
|
||||
Assert.AreEqual("Apple", (string)o["Name"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1940,7 +1942,9 @@ Parameter name: arrayIndex");
|
||||
o.WriteTo(writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
token.WriteTo(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
|
||||
@@ -729,14 +729,14 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
|
||||
JObject o = new JObject
|
||||
{
|
||||
{"prop1", "value1"}
|
||||
{ "prop1", "value1" }
|
||||
};
|
||||
|
||||
JToken t1 = a[1][0];
|
||||
JToken t2 = o["prop1"];
|
||||
|
||||
List<JToken> source = new List<JToken> {t1, t2};
|
||||
|
||||
List<JToken> source = new List<JToken> { t1, t2 };
|
||||
|
||||
List<JToken> ancestors = source.AncestorsAndSelf().ToList();
|
||||
Assert.AreEqual(6, ancestors.Count());
|
||||
Assert.AreEqual(t1, ancestors[0]);
|
||||
@@ -760,7 +760,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
|
||||
JObject o = new JObject
|
||||
{
|
||||
{"prop1", "value1"}
|
||||
{ "prop1", "value1" }
|
||||
};
|
||||
|
||||
JToken t1 = a[1][0];
|
||||
@@ -809,7 +809,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
|
||||
JObject o = new JObject
|
||||
{
|
||||
{"prop1", "value1"}
|
||||
{ "prop1", "value1" }
|
||||
};
|
||||
|
||||
List<JContainer> source = new List<JContainer> { a, o };
|
||||
@@ -859,7 +859,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
|
||||
JObject o = new JObject
|
||||
{
|
||||
{"prop1", "value1"}
|
||||
{ "prop1", "value1" }
|
||||
};
|
||||
|
||||
List<JContainer> source = new List<JContainer> { a, o };
|
||||
|
||||
@@ -765,9 +765,9 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
|
||||
new JProperty("prop",
|
||||
new JArray(
|
||||
values.Select(v => new JObject(new JProperty("childProp", v)))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
IList<JToken> t = o.SelectTokens("$.prop[?(@.childProp =='ff2dc672-6e15-4aa2-afb0-18f4f69596ad')]").ToList();
|
||||
Assert.AreEqual(2, t.Count);
|
||||
|
||||
@@ -42,6 +42,7 @@ using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Linq.JsonPath
|
||||
@@ -479,8 +480,8 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
|
||||
{
|
||||
JPath path = new JPath("Blah[0]..Two.Three[1].Four");
|
||||
Assert.AreEqual(6, path.Filters.Count);
|
||||
Assert.AreEqual("Blah", ((FieldFilter) path.Filters[0]).Name);
|
||||
Assert.AreEqual(0, ((ArrayIndexFilter) path.Filters[1]).Index);
|
||||
Assert.AreEqual("Blah", ((FieldFilter)path.Filters[0]).Name);
|
||||
Assert.AreEqual(0, ((ArrayIndexFilter)path.Filters[1]).Index);
|
||||
Assert.AreEqual("Two", ((ScanFilter)path.Filters[2]).Name);
|
||||
Assert.AreEqual("Three", ((FieldFilter)path.Filters[3]).Name);
|
||||
Assert.AreEqual(1, ((ArrayIndexFilter)path.Filters[4]).Index);
|
||||
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Linq.JsonPath
|
||||
@@ -80,29 +81,29 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
|
||||
|
||||
JObject o1 = new JObject
|
||||
{
|
||||
{"Title","Title!"},
|
||||
{"FirstName", "FirstName!"},
|
||||
{"LastName", "LastName!"}
|
||||
{ "Title", "Title!" },
|
||||
{ "FirstName", "FirstName!" },
|
||||
{ "LastName", "LastName!" }
|
||||
};
|
||||
|
||||
Assert.IsTrue(compositeExpression.IsMatch(o1));
|
||||
|
||||
JObject o2 = new JObject
|
||||
{
|
||||
{"Title","Title!"},
|
||||
{"FirstName", "FirstName!"}
|
||||
{ "Title", "Title!" },
|
||||
{ "FirstName", "FirstName!" }
|
||||
};
|
||||
|
||||
Assert.IsFalse(compositeExpression.IsMatch(o2));
|
||||
|
||||
JObject o3 = new JObject
|
||||
{
|
||||
{"Title","Title!"}
|
||||
{ "Title", "Title!" }
|
||||
};
|
||||
|
||||
Assert.IsFalse(compositeExpression.IsMatch(o3));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void OrExpressionTest()
|
||||
{
|
||||
@@ -138,24 +139,24 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
|
||||
|
||||
JObject o1 = new JObject
|
||||
{
|
||||
{"Title","Title!"},
|
||||
{"FirstName", "FirstName!"},
|
||||
{"LastName", "LastName!"}
|
||||
{ "Title", "Title!" },
|
||||
{ "FirstName", "FirstName!" },
|
||||
{ "LastName", "LastName!" }
|
||||
};
|
||||
|
||||
Assert.IsTrue(compositeExpression.IsMatch(o1));
|
||||
|
||||
JObject o2 = new JObject
|
||||
{
|
||||
{"Title","Title!"},
|
||||
{"FirstName", "FirstName!"}
|
||||
{ "Title", "Title!" },
|
||||
{ "FirstName", "FirstName!" }
|
||||
};
|
||||
|
||||
Assert.IsTrue(compositeExpression.IsMatch(o2));
|
||||
|
||||
JObject o3 = new JObject
|
||||
{
|
||||
{"Title","Title!"}
|
||||
{ "Title", "Title!" }
|
||||
};
|
||||
|
||||
Assert.IsFalse(compositeExpression.IsMatch(o3));
|
||||
@@ -195,4 +196,4 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
|
||||
Assert.IsFalse(e2.IsMatch(new JArray(4, 5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -722,7 +722,7 @@ keyword such as type of business.""
|
||||
Post p = new Post
|
||||
{
|
||||
Title = "How to use FromObject",
|
||||
Categories = new [] { "LINQ to JSON" }
|
||||
Categories = new[] { "LINQ to JSON" }
|
||||
};
|
||||
|
||||
// serialize Post to JSON then parse JSON – SLOW!
|
||||
@@ -1110,8 +1110,8 @@ keyword such as type of business.""
|
||||
}
|
||||
]
|
||||
}
|
||||
}", o.ToString());
|
||||
|
||||
}", o.ToString());
|
||||
|
||||
CustomAssert.IsInstanceOfType(typeof(JObject), o);
|
||||
CustomAssert.IsInstanceOfType(typeof(JObject), o["channel"]);
|
||||
Assert.AreEqual("James Newton-King", (string)o["channel"]["title"]);
|
||||
|
||||
@@ -42,6 +42,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Linq
|
||||
@@ -103,10 +104,10 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Property1 = new { SubProperty1 = 1 }
|
||||
});
|
||||
var right = (JArray)JToken.FromObject(new object[]
|
||||
{
|
||||
new { Property1 = 1 },
|
||||
new { Property1 = 1 }
|
||||
});
|
||||
{
|
||||
new { Property1 = 1 },
|
||||
new { Property1 = 1 }
|
||||
});
|
||||
|
||||
left.Merge(right);
|
||||
|
||||
@@ -182,7 +183,6 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Property2 = 3,
|
||||
Property3 = new
|
||||
{
|
||||
|
||||
},
|
||||
Property5 = (object)null
|
||||
}
|
||||
@@ -282,25 +282,25 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
public void MergeMismatchingTypesInArray()
|
||||
{
|
||||
var left = (JArray)JToken.FromObject(new object[]
|
||||
{
|
||||
true,
|
||||
null,
|
||||
new { Property1 = 1 },
|
||||
new object[] { 1 },
|
||||
new { Property1 = 1 },
|
||||
1,
|
||||
new object[] { 1 }
|
||||
});
|
||||
{
|
||||
true,
|
||||
null,
|
||||
new { Property1 = 1 },
|
||||
new object[] { 1 },
|
||||
new { Property1 = 1 },
|
||||
1,
|
||||
new object[] { 1 }
|
||||
});
|
||||
var right = (JArray)JToken.FromObject(new object[]
|
||||
{
|
||||
1,
|
||||
5,
|
||||
new object[] { 1 },
|
||||
new { Property1 = 1 },
|
||||
true,
|
||||
new { Property1 = 1 },
|
||||
null
|
||||
});
|
||||
{
|
||||
1,
|
||||
5,
|
||||
new object[] { 1 },
|
||||
new { Property1 = 1 },
|
||||
true,
|
||||
new { Property1 = 1 },
|
||||
null
|
||||
});
|
||||
|
||||
left.Merge(right, new JsonMergeSettings
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user