public void enumeratorTest(IEnumerable <Command> commands) { ReferenceSet <Key> set = null; Key[] domain = makeKeys(getDomainSize(commands)); foreach (Command cmd in commands) { runCommand(ref set, domain, cmd); var enumerator = set.GetEnumerator(); var enumerator2 = ((IEnumerable <Key>)set).GetEnumerator(); var enumerator3 = ((IEnumerable)set).GetEnumerator(); var enumResult1 = new List <Key>(); while (enumerator.MoveNext()) { enumResult1.Add(enumerator.Current); } var enumResult2 = new List <Key>(); while (enumerator2.MoveNext()) { enumResult2.Add(enumerator2.Current); } var enumResult3 = new List <Key>(); while (enumerator3.MoveNext()) { enumResult3.Add(Assert.IsType <Key>(enumerator3.Current)); } bool[] keyMap = makeKeyMap(domain.Length, cmd.keysInSet); for (int i = 0; i < domain.Length; i++) { Assert.Equal(keyMap[i], enumResult1.Any(x => x == domain[i])); Assert.Equal(keyMap[i], enumResult2.Any(x => x == domain[i])); Assert.Equal(keyMap[i], enumResult3.Any(x => x == domain[i])); } Assert.Throws <NotImplementedException>(() => enumerator2.Reset()); Assert.Throws <NotImplementedException>(() => enumerator3.Reset()); enumerator.Dispose(); enumerator2.Dispose(); } }