AlgoLib.Tests.TrieTests.CopyTo C# (CSharp) Метод

CopyTo() приватный Метод

private CopyTo ( ) : void
Результат void
        public void CopyTo()
        {
            var trie = new Trie<bool>();

            trie.Add("ABC", true);
            trie.Add("AB", false);
            trie.Add("ADE", true);
            trie.Add("ABCDE", false);

            var destinationArray = new KeyValuePair<string, bool>[6];

            ((ICollection<KeyValuePair<string, bool>>)trie).CopyTo(destinationArray, 1);

            var result = destinationArray.Where(i => i.Key != null).OrderBy(i => i.Key).ToArray();

            var expected = new[]
                {
                    new KeyValuePair<string, bool>("AB", false),
                    new KeyValuePair<string, bool>("ABC", true),
                    new KeyValuePair<string, bool>("ABCDE", false),
                    new KeyValuePair<string, bool>("ADE", true)
                };

            Assert.AreEqual(new KeyValuePair<string, bool>(), destinationArray[0]);
            Assert.AreEqual(new KeyValuePair<string, bool>(), destinationArray[destinationArray.Length - 1]);
            Assert.IsTrue(expected.SequenceEqual(result));
        }