public void toArrayTest(IEnumerable <Command> commands) { ReferenceSet <Key> set = null; Key[] domain = makeKeys(getDomainSize(commands)); foreach (Command cmd in commands) { runCommand(ref set, domain, cmd); Key[] array = set.toArray(); bool[] keyMap = makeKeyMap(domain.Length, cmd.keysInSet); Assert.Equal((cmd.keysInSet == null) ? 0 : cmd.keysInSet.Count(), array.Length); for (int i = 0; i < domain.Length; i++) { Assert.Equal(keyMap[i], array.Any(x => x == domain[i])); } } }