Beispiel #1
0
            public void SortedEnumerable_RepeatWithDelegate_EnumeratesRepeatedItem()
            {
                int source = 13;
                ISortedEnumerable <int> result = SortedEnumerableSource.Repeat(source, (x, y) => Comparer <int> .Default.Compare(y, x), 3);

                Assert.IsTrue(result.SequenceEqual(new[] { 13, 13, 13 }), "Item should be repeated.");
            }
Beispiel #2
0
            public void SortedEnumerable_Repeat_EnumeratesRepeatedItem()
            {
                int source = 13;
                ISortedEnumerable <int> result = SortedEnumerableSource.Repeat(source, 3);

                Assert.IsTrue(result.SequenceEqual(new[] { 13, 13, 13 }), "Item should be repeated.");
            }
Beispiel #3
0
            public void SortedEnumerable_ReturnWithComparer_EnumeratesSingleItem()
            {
                int source = 13;
                ISortedEnumerable <int> result = SortedEnumerableSource.Return(source, Comparer <int> .Default);

                Assert.IsTrue(result.SequenceEqual(new[] { 13 }), "Item should be enumerated.");
            }
Beispiel #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.");
            }
Beispiel #5
0
            public void SortedEnumerable_EmptyWithDelegate_IsEmpty()
            {
                ISortedEnumerable <string> sorted = SortedEnumerableSource.Empty <string>((x, y) => StringComparer.InvariantCultureIgnoreCase.Compare(y, x));

                Assert.IsTrue(sorted.SequenceEqual(new string[] { }), "Empty should be empty.");
            }
Beispiel #6
0
            public void SortedEnumerable_Empty_IsEmpty()
            {
                ISortedEnumerable <string> sorted = SortedEnumerableSource.Empty <string>();

                Assert.IsTrue(sorted.SequenceEqual(new string[] { }), "Empty should be empty.");
            }