public void GetEnumeratorTest() { IEnumerable target = new JsonArray(AnyInstance.AnyGuid); IEnumerator enumerator = target.GetEnumerator(); Assert.True(enumerator.MoveNext()); Assert.Equal(AnyInstance.AnyGuid, (Guid)(JsonValue)enumerator.Current); Assert.False(enumerator.MoveNext()); target = new JsonObject(); enumerator = target.GetEnumerator(); Assert.False(enumerator.MoveNext()); }
public void GetEnumeratorTest() { string key1 = AnyInstance.AnyString; string key2 = AnyInstance.AnyString2; JsonValue value1 = AnyInstance.AnyJsonValue1; JsonValue value2 = AnyInstance.AnyJsonValue2; JsonObject target = new JsonObject { { key1, value1 }, { key2, value2 } }; IEnumerator <KeyValuePair <string, JsonValue> > enumerator = target.GetEnumerator(); Assert.True(enumerator.MoveNext()); bool key1IsFirst = key1 == enumerator.Current.Key; if (key1IsFirst) { Assert.Equal(key1, enumerator.Current.Key); Assert.Equal(value1, enumerator.Current.Value); } else { Assert.Equal(key2, enumerator.Current.Key); Assert.Equal(value2, enumerator.Current.Value); } Assert.True(enumerator.MoveNext()); if (key1IsFirst) { Assert.Equal(key2, enumerator.Current.Key); Assert.Equal(value2, enumerator.Current.Value); } else { Assert.Equal(key1, enumerator.Current.Key); Assert.Equal(value1, enumerator.Current.Value); } Assert.False(enumerator.MoveNext()); }
public void GetEnumeratorTest() { string key1 = AnyInstance.AnyString; string key2 = AnyInstance.AnyString2; JsonValue value1 = AnyInstance.AnyJsonValue1; JsonValue value2 = AnyInstance.AnyJsonValue2; JsonObject target = new JsonObject { { key1, value1 }, { key2, value2 } }; IEnumerator<KeyValuePair<string, JsonValue>> enumerator = target.GetEnumerator(); Assert.IsTrue(enumerator.MoveNext()); bool key1IsFirst = key1 == enumerator.Current.Key; if (key1IsFirst) { Assert.AreEqual(key1, enumerator.Current.Key); Assert.AreEqual(value1, enumerator.Current.Value); } else { Assert.AreEqual(key2, enumerator.Current.Key); Assert.AreEqual(value2, enumerator.Current.Value); } Assert.IsTrue(enumerator.MoveNext()); if (key1IsFirst) { Assert.AreEqual(key2, enumerator.Current.Key); Assert.AreEqual(value2, enumerator.Current.Value); } else { Assert.AreEqual(key1, enumerator.Current.Key); Assert.AreEqual(value1, enumerator.Current.Value); } Assert.IsFalse(enumerator.MoveNext()); }
public void GetEnumeratorTest() { IEnumerable target = new JsonArray(AnyInstance.AnyGuid); IEnumerator enumerator = target.GetEnumerator(); Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual(AnyInstance.AnyGuid, (Guid)(JsonValue)enumerator.Current); Assert.IsFalse(enumerator.MoveNext()); target = new JsonObject(); enumerator = target.GetEnumerator(); Assert.IsFalse(enumerator.MoveNext()); }