public void Ctor_IEnumerable() { // Workaround xunit/xunit#987: InvalidOperationException thrown if this is in MemberData KeyValuePair<string, JsonValue>[] items = new KeyValuePair<string, JsonValue>[] { new KeyValuePair<string, JsonValue>("key", new JsonPrimitive(true)) }; JsonObject obj = new JsonObject((IEnumerable<KeyValuePair<string, JsonValue>>)items); Assert.Equal(items.Length, obj.Count); for (int i = 0; i < items.Length; i++) { Assert.Equal(items[i].Value.ToString(), obj[items[i].Key].ToString()); JsonValue value; Assert.True(obj.TryGetValue(items[i].Key, out value)); Assert.Equal(items[i].Value.ToString(), value.ToString()); } }
public void TryGetValue_NoSuchKey_ReturnsNull() { JsonObject obj = new JsonObject(); JsonValue value; Assert.False(obj.TryGetValue("no-such-key", out value)); Assert.Null(value); }