예제 #1
0
        public void TestCtors()
        {
            var empty = new RedBlackSetTester<char>();
            Assert.That(empty.Empty, Is.True);
            Assert.That(empty.Count(), Is.EqualTo(0));
            Assert.That(empty.ToList(), Is.Empty);
            empty.Add('1');
            Assert.That(empty.Empty, Is.False);
            Assert.That(empty.Count(), Is.EqualTo(1));

            WithRandomNumbers(list =>
                {
                    var range = Enumerable.Range(42, list.Count);
                    var two = new RedBlackMapTester<int, int>(list, range);
                    var prs = new RedBlackMapTester<int, int>(list.Zip<int, int, KeyValuePair<int, int>>(range, RedBlackMap<int, int>.KeyValuePair.Create));
                    var tup = new RedBlackMapTester<int, int>(list.Zip<int, int, Tuple<int, int>>(range, Tuple.Create));
                    Assert.That(two.ToArray(), Is.EqualTo(prs.ToList()));
                    Assert.That(two.ToArray(), Is.EqualTo(tup.ToList()));
                });

            Assert.That(() =>
                {
                    new RedBlackMapTester<int, int>(Enumerable.Range(1, 3), Enumerable.Range(1, 4));
                }, Throws.ArgumentException);
        }