Exemplo n.º 1
0
            public void SortedEnumerable_IndexOf_WithInvalidItemValue_DoesNotFindItem()
            {
                IEnumerable <string>       source = new[] { "a", "a", "c" };
                ISortedEnumerable <string> sorted = source.AsSorted();
                int result = sorted.IndexOf("b");

                Assert.AreEqual(-1, result, "Item should not be found.");
            }
Exemplo n.º 2
0
            public void SortedEnumerable_IndexOf_WithInvalidItem_DoesNotFindItem()
            {
                IEnumerable <string>       source = new[] { "a", "a", "c" };
                ISortedEnumerable <string> sorted = source.AsSorted();
                int result = sorted.IndexOf(x => StringComparer.InvariantCultureIgnoreCase.Compare("b", x));

                Assert.AreEqual(-1, result, "Item should not be found.");
            }
Exemplo n.º 3
0
            public void SortedEnumerable_IndexOf_WithValidItemValue_FindsItem()
            {
                IEnumerable <string>       source = new[] { "a", "a", "c" };
                ISortedEnumerable <string> sorted = source.AsSorted();
                int result = sorted.IndexOf("a");

                Assert.AreEqual(0, result, "Item should be found.");
            }
Exemplo n.º 4
0
            public void SortedDictionary_AsSorted_EnumeratesIdenticalSequence()
            {
                SortedDictionary <int, string> source = new SortedDictionary <int, string>();

                source.Add(0, "a");
                source.Add(1, "c");
                source.Add(2, "b");
                ISortedEnumerable <KeyValuePair <int, string> > result = source.AsSorted();

                Assert.IsTrue(result.SequenceEqual(new[] { new KeyValuePair <int, string>(0, "a"), new KeyValuePair <int, string>(1, "c"), new KeyValuePair <int, string>(2, "b") }), "AsSorted should not change the sequence.");
                Assert.AreEqual(0, result.IndexOf(new KeyValuePair <int, string>(0, "a")), "Could not find item in sorted dictionary.");
            }