public void TryParseThrowsInvalidMaxDepth() { JObject value; Assert.ThrowsArgumentGreaterThan(() => FormUrlEncodedJson.TryParse(CreateQuery(), -1, out value), "maxDepth", "0", -1); Assert.ThrowsArgumentGreaterThan(() => FormUrlEncodedJson.TryParse(CreateQuery(), 0, out value), "maxDepth", "0", 0); }
public void TryParseReturnsFalseMaxDepthExceeded() { JObject value; // Depth of 'a[b]=1' is 3 IEnumerable <KeyValuePair <string, string> > query = CreateQuery(new KeyValuePair <string, string>("a[b]", "1")); Assert.False(FormUrlEncodedJson.TryParse(query, 2, out value), "Parse should have failed due to too high depth."); // This should succeed Assert.True(FormUrlEncodedJson.TryParse(query, 3, out value), "Expected non-null JsonObject instance"); Assert.NotNull(value); }
public void TryParseThrowsOnNull() { JObject value; Assert.ThrowsArgumentNull(() => FormUrlEncodedJson.TryParse(null, out value), null); }