public void DoubleDeepEquals() { JArray a = new JArray( double.NaN, double.PositiveInfinity, double.NegativeInfinity ); JArray a2 = (JArray)a.DeepClone(); Assert.IsTrue(a.DeepEquals(a2)); double d = 1 + 0.1 + 0.1 + 0.1; JValue v1 = new JValue(d); JValue v2 = new JValue(1.3); Assert.IsTrue(v1.DeepEquals(v2)); }
public void DeepClone() { JArray a = new JArray( 5, new JArray(1), new JArray(1, 2), new JArray(1, 2, 3), new JObject( new JProperty("First", new JValue(Encoding.UTF8.GetBytes("Hi"))), new JProperty("Second", 1), new JProperty("Third", null), new JProperty("Fourth", new JConstructor("Date", 12345)), new JProperty("Fifth", double.PositiveInfinity), new JProperty("Sixth", double.NaN) ) ); JArray a2 = (JArray)a.DeepClone(); Console.WriteLine(a2.ToString(Formatting.Indented)); Assert.IsTrue(a.DeepEquals(a2)); }
public void DeepClone() { JArray a = new JArray( 5, new JArray(1), new JArray(1, 2), new JArray(1, 2, 3), new JObject( new JProperty("First", new JValue(Encoding.UTF8.GetBytes("Hi"))), new JProperty("Second", 1), new JProperty("Third", null), new JProperty("Fourth", new JConstructor("Date", 12345)), new JProperty("Fifth", double.PositiveInfinity), new JProperty("Sixth", double.NaN) ) ); JArray a2 = (JArray)a.DeepClone(); StringAssert.AreEqual(@"[ 5, [ 1 ], [ 1, 2 ], [ 1, 2, 3 ], { ""First"": ""SGk="", ""Second"": 1, ""Third"": null, ""Fourth"": new Date( 12345 ), ""Fifth"": ""Infinity"", ""Sixth"": ""NaN"" } ]", a2.ToString(Formatting.Indented)); Assert.IsTrue(a.DeepEquals(a2)); }
static JObject CreateSwaggerPathForEntity(IEdmEntitySet entitySet) { var keyParameters = new JArray(); foreach (var key in entitySet.EntityType().Key()) { string format; string type = GetPrimitiveTypeAndFormat(key.Type.Definition as IEdmPrimitiveType, out format); keyParameters.Parameter(key.Name, "path", "key: " + key.Name, type, format); } return new JObject() { { "get", new JObject() .Summary("Get entity from " + entitySet.Name + " by key.") .Description("Returns the entity with the key from " + entitySet.Name) .Tags(entitySet.Name) .Parameters((keyParameters.DeepClone() as JArray) .Parameter("$select", "query", "description", "string") ) .Responses(new JObject() .Response("200", "EntitySet " + entitySet.Name, entitySet.EntityType()) .DefaultErrorResponse() ) }, { "patch", new JObject() .Summary("Update entity in EntitySet " + entitySet.Name) .Description("Update entity in EntitySet " + entitySet.Name) .Tags(entitySet.Name) .Parameters((keyParameters.DeepClone() as JArray) .Parameter(entitySet.EntityType().Name, "body", "The entity to patch", entitySet.EntityType()) ) .Responses(new JObject() .Response("204", "Empty response") .DefaultErrorResponse() ) }, { "delete", new JObject() .Summary("Delete entity in EntitySet " + entitySet.Name) .Description("Delete entity in EntitySet " + entitySet.Name) .Tags(entitySet.Name) .Parameters((keyParameters.DeepClone() as JArray) .Parameter("If-Match", "header", "If-Match header", "string") ) .Responses(new JObject() .Response("204", "Empty response") .DefaultErrorResponse() ) } }; }