Esempio n. 1
0
        public void TestCacheWorks()
        {
            var init = new int[] { 2, 3, 4, 5 };

            var t = new RedBlackSetTester<int>(init);

            Assert.That(t.Cache, Is.EqualTo(init));
            Assert.That(t.Remove(4), Is.True);
            var remove = init.Where(i => i != 4);
            Assert.That(t.Add(2), Is.False);
            Assert.That(t.Cache, Is.EquivalentTo(remove));
            Assert.That(t.Add(7), Is.True);
            var add = remove.Concat(Enumerable.Repeat(7, 1));
            Assert.That(t.Cache, Is.EquivalentTo(add));
            t.Clear();
            Assert.That(t.Cache, Is.Empty);
        }
Esempio n. 2
0
 public void TestSymmetricExceptWith()
 {
     var a = new RedBlackSetTester<int>(_odd.Where(UpTo100));
     Assert.That(() => a.SymmetricExceptWith(null), Throws.InstanceOf<ArgumentNullException>());
     a.SymmetricExceptWith(_even.Where(UpTo100));
     Assert.That(a.SetEquals(_numbers));
     a.Clear();
     a.AddRange(_primes);
     a.SymmetricExceptWith(_odd.Where(UpTo100).Concat(Enumerable.Repeat(2, 2)));
     Assert.That(a.Contains(_primes.First()), Is.False);
     Assert.That(_primes.Skip(1).All(p => !a.Contains(p)));
 }