public static void Test3_Negative()
 {
     HashSet<Item> hashSet = new HashSet<Item>();
     Item[] items = new Item[0];
     HashSetTestSupport<Item> driver = new HashSetTestSupport<Item>(hashSet, Item.GenerateNext, items);
     driver.VerifyHashSet_NegativeTests();
 }
 public static void Test1_Negative()
 {
     HashSet<int> hashSet = new HashSet<int>();
     int[] items = new int[0];
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
     driver.VerifyHashSet_NegativeTests();
 }
 public static void Test2()
 {
     HashSet<ValueItem> hashSet = new HashSet<ValueItem>();
     ValueItem[] items = new ValueItem[0];
     HashSetTestSupport<ValueItem> driver = new HashSetTestSupport<ValueItem>(hashSet, ValueItem.GenerateNext, items);
     driver.VerifyHashSetTests();
 }
Example #4
0
        public static void Ctor_IEnumerable_Duplicate_Neg()
        {
            int[]                    items   = new int[] { 4, -23, -23, -2, 4, 6, 0, 4, 123, -4, 123 };
            HashSet <int>            hashSet = new HashSet <int>(items);
            HashSetTestSupport <int> driver  = new HashSetTestSupport <int>(hashSet, s_intGenerator, items);

            driver.VerifyHashSet_NegativeTests();
        }
Example #5
0
        public static void Ctor_IEnumerable_Multiple()
        {
            int[]                    items   = new int[] { -23, -2, 4, 6, 0, 123, -4 };
            HashSet <int>            hashSet = new HashSet <int>(items);
            HashSetTestSupport <int> driver  = new HashSetTestSupport <int>(hashSet, s_intGenerator, items);

            driver.VerifyHashSetTests();
        }
Example #6
0
        public static void Ctor_IEnumerable_empty()
        {
            int[]                    items   = new int[0];
            HashSet <int>            hashSet = new HashSet <int>(items);
            HashSetTestSupport <int> driver  = new HashSetTestSupport <int>(hashSet, s_intGenerator, items);

            driver.VerifyHashSetTests();
        }
Example #7
0
        public static void Ctor_IEnumerable_Single_Neg()
        {
            int[]                    items   = new int[] { -23 };
            HashSet <int>            hashSet = new HashSet <int>(items);
            HashSetTestSupport <int> driver  = new HashSetTestSupport <int>(hashSet, s_intGenerator, items);

            driver.VerifyHashSet_NegativeTests();
        }
Example #8
0
        public static void TrimExcess_Test1()
        {
            HashSet <int> hashSet;

            hashSet = new HashSet <int>();
            hashSet.TrimExcess();

            HashSetTestSupport <int> .VerifyHashSet(hashSet, new int[0], EqualityComparer <int> .Default);
        }
        public static void HashSet_Add_T_Default_NotInSet()
        {
            HashSet <int> hashSet = new HashSet <int>(new int[] { 1, 2, 3, 4, 5, 6, 7 });
            int           item    = 0;
            bool          added   = hashSet.Add(item);

            Assert.True(added); //"Error: Add returned wrong value"
            HashSetTestSupport <int> .VerifyHashSet(hashSet, new int[] { 1, 2, 3, 6, 7, 4, 0, 5 }, hashSet.Comparer);
        }
Example #10
0
        public static void ICollectionAdd_Test1()
        {
            HashSet <Item> hashSet = new HashSet <Item>();
            Item           item    = new Item(1);

            ((ICollection <Item>)hashSet).Add(item);

            HashSetTestSupport <Item> .VerifyHashSet(hashSet, new Item[] { item }, EqualityComparer <Item> .Default);
        }
Example #11
0
        public static void HashSetConstructor_IEn_IEq_Comparer_Custom()
        {
            Item[] items = new Item[] { new Item(1), new Item(2), new Item(3), new Item(4) };
            IEqualityComparer <Item>  comparer = new ItemEqualityComparer();
            HashSet <Item>            hashSet  = new HashSet <Item>(items, comparer);
            HashSetTestSupport <Item> driver   = new HashSetTestSupport <Item>(hashSet, Item.GenerateNext, items, comparer);

            driver.VerifyHashSetTests();
        }
Example #12
0
        public static void Test3()
        {
            HashSet <Item> hashSet = new HashSet <Item>();

            Item[] items = new Item[0];
            HashSetTestSupport <Item> driver = new HashSetTestSupport <Item>(hashSet, Item.GenerateNext, items);

            driver.VerifyHashSetTests();
        }
Example #13
0
        public static void Test1_Negative()
        {
            HashSet <int> hashSet = new HashSet <int>();

            int[] items = new int[0];
            HashSetTestSupport <int> driver = new HashSetTestSupport <int>(hashSet, s_intGenerator, items);

            driver.VerifyHashSet_NegativeTests();
        }
Example #14
0
        public static void Ctor_IEnumerable_HashSet_Fresh_HashSet()
        {
            HashSet <int> source  = new HashSet <int>();
            HashSet <int> hashSet = new HashSet <int>(source);

            HashSetTestSupport <int> driver = new HashSetTestSupport <int>(hashSet, s_intGenerator, new int[0]);

            driver.VerifyHashSetTests();
        }
Example #15
0
        public static void Test2_Negative()
        {
            HashSet <ValueItem> hashSet = new HashSet <ValueItem>();

            ValueItem[] items = new ValueItem[0];
            HashSetTestSupport <ValueItem> driver = new HashSetTestSupport <ValueItem>(hashSet, ValueItem.GenerateNext, items);

            driver.VerifyHashSet_NegativeTests();
        }
        public static void HashSet_Add_Empty()
        {
            HashSet <Item> hashSet = new HashSet <Item>();
            Item           item    = new Item(1);
            bool           added   = hashSet.Add(item);

            Assert.True(added); //"Error: Add returned wrong value"
            HashSetTestSupport <Item> .VerifyHashSet(hashSet, new Item[] { item }, EqualityComparer <Item> .Default);
        }
        public static void IsIntersectWith_Test54()
        {
            HashSet <ValueItem>     hashSet;
            IEnumerable <ValueItem> other;

            SetCollectionComparerTests.SetupTest12(out hashSet, out other);
            hashSet.IntersectWith(other);

            HashSetTestSupport <ValueItem> .VerifyHashSet(hashSet, new ValueItem[0], hashSet.Comparer);
        }
        public static void IsIntersectWith_Test42()
        {
            HashSet <Item>     hashSet;
            IEnumerable <Item> other;

            SetCollectionRelationshipTests.SetupTest42(out hashSet, out other);
            hashSet.IntersectWith(other);

            HashSetTestSupport <Item> .VerifyHashSet(hashSet, new Item[] { new Item(1) }, hashSet.Comparer);
        }
        public static void IsIntersectWith_Test37()
        {
            HashSet <int>     hashSet;
            IEnumerable <int> other;

            SetCollectionRelationshipTests.SetupTest37(out hashSet, out other);
            hashSet.IntersectWith(other);

            HashSetTestSupport <int> .VerifyHashSet(hashSet, new int[0], hashSet.Comparer);
        }
        public static void HashSet_Remove_T_Default_NotInSet()
        {
            HashSet <int> hashSet = new HashSet <int>(new int[] { 1, 2, 3, 4, 5, 6, 7 });
            int           item    = 0;
            bool          removed = hashSet.Remove(item);

            Assert.False(removed); //"Error: Remove returned wrong value"

            HashSetTestSupport <int> .VerifyHashSet(hashSet, new int[] { 1, 2, 3, 6, 7, 4, 5 }, hashSet.Comparer);
        }
Example #21
0
        public static void Ctor_IEnumerable_HashSet_Empty_Neg()
        {
            var           items  = new int[0];
            HashSet <int> source = new HashSet <int>(items);

            HashSet <int>            hashSet = new HashSet <int>(source);
            HashSetTestSupport <int> driver  = new HashSetTestSupport <int>(hashSet, s_intGenerator, items);

            driver.VerifyHashSet_NegativeTests();
        }
        public static void HashSet_Remove_Empty()
        {
            HashSet <Item> hashSet = new HashSet <Item>();
            Item           item    = new Item(1);
            bool           removed = hashSet.Remove(item);

            Assert.False(removed); //"Error: Remove returned wrong value"

            HashSetTestSupport <Item> .VerifyHashSet(hashSet, new Item[0], EqualityComparer <Item> .Default);
        }
Example #23
0
        public static void HashSetConstructor_IEn_IEq_Comparer_NotIEquatable()
        {
            IEqualityComparer <Item> defaultComparer = EqualityComparer <Item> .Default;

            Item[]                    items   = new Item[] { new Item(1), new Item(2), new Item(3), new Item(4) };
            HashSet <Item>            hashSet = new HashSet <Item>(items, defaultComparer);
            HashSetTestSupport <Item> driver  = new HashSetTestSupport <Item>(hashSet, Item.GenerateNext, items, defaultComparer);

            driver.VerifyHashSetTests();
        }
        public static void IsExceptWith_Test7()
        {
            HashSet <Item>     hashSet;
            IEnumerable <Item> other;

            SetCollectionRelationshipTests.SetupTest7(out hashSet, out other);
            hashSet.ExceptWith(other);

            HashSetTestSupport <Item> .VerifyHashSet(hashSet, new Item[0], hashSet.Comparer);
        }
        public static void IsExceptWith_Test37()
        {
            HashSet <int>     hashSet;
            IEnumerable <int> other;

            SetCollectionRelationshipTests.SetupTest37(out hashSet, out other);
            hashSet.ExceptWith(other);

            HashSetTestSupport <int> .VerifyHashSet(hashSet, new int[] { 1, 2, 3, 4, 6, 7, 5 }, hashSet.Comparer);
        }
        public static void IsExceptWith_Test57()
        {
            HashSet <HashSet <IEnumerable> >     hashSet;
            IEnumerable <HashSet <IEnumerable> > other;

            SetCollectionComparerTests.SetupTest15(out hashSet, out other);
            hashSet.ExceptWith(other);

            HashSetTestSupport <HashSet <IEnumerable> > .VerifyHashSet(hashSet, new HashSet <IEnumerable> [0], hashSet.Comparer);
        }
        public static void Contains_Test1()
        {
            HashSet <Item> hashSet  = new HashSet <Item>();
            Item           item     = new Item(1);
            bool           contains = hashSet.Contains(item);

            Assert.False(contains); //"Error: Contains returned wrong value"

            HashSetTestSupport <Item> .VerifyHashSet(hashSet, new Item[0], EqualityComparer <Item> .Default);
        }
Example #28
0
        public static void ICollectionAdd_Test19()
        {
            HashSet <ValueItem> hashSet;
            ValueItem           item;

            SetItemComparerTests.SetupTest4(out hashSet, out item);
            ((ICollection <ValueItem>)hashSet).Add(item);

            HashSetTestSupport <ValueItem> .VerifyHashSet(hashSet, new ValueItem[] { item, new ValueItem(5, 4), new ValueItem(5, -5) }, hashSet.Comparer);
        }
Example #29
0
        public static void Ctor_IEnumerable_ManyDuplicates()
        {
            int[]         items   = new int[] { 4, -23, -23, -2, 4, 6, 0, 4, 123, -4, 123 };
            HashSet <int> hashSet = new HashSet <int>(Enumerable.Range(0, 40).SelectMany(i => items).ToArray());

            int[] expected = new int[] { -23, -2, 4, 6, 0, 123, -4 };
            HashSetTestSupport <int> driver = new HashSetTestSupport <int>(hashSet, s_intGenerator, expected);

            driver.VerifyHashSetTests();
        }
Example #30
0
        public static void HashSetConstructor_IEn_IEq_Comparer_Default()
        {
            IEqualityComparer <ValueItem> defaultComparer = EqualityComparer <ValueItem> .Default;

            ValueItem[]                    items   = new ValueItem[] { new ValueItem(1, -1), new ValueItem(2, -2), new ValueItem(3, -3), new ValueItem(4, -4) };
            HashSet <ValueItem>            hashSet = new HashSet <ValueItem>(items, defaultComparer);
            HashSetTestSupport <ValueItem> driver  = new HashSetTestSupport <ValueItem>(hashSet, ValueItem.GenerateNext, items, defaultComparer);

            driver.VerifyHashSetTests();
        }
Example #31
0
        public static void Ctor_IEnumerable_Duplicate()
        {
            int[]         items   = new int[] { 4, -23, -23, -2, 4, 6, 0, 4, 123, -4, 123 };
            HashSet <int> hashSet = new HashSet <int>(items);

            int[] expected = new int[] { -23, -2, 4, 6, 0, 123, -4 };
            HashSetTestSupport <int> driver = new HashSetTestSupport <int>(hashSet, s_intGenerator, expected);

            driver.VerifyHashSetTests();
        }
        public static void IsExceptWith_Test68()
        {
            HashSet <ValueItem>     hashSet;
            IEnumerable <ValueItem> other;

            SetCollectionDuplicateItemTests.SetupTest11(out hashSet, out other);
            hashSet.ExceptWith(other);

            HashSetTestSupport <ValueItem> .VerifyHashSet(hashSet, new ValueItem[0], hashSet.Comparer);
        }
Example #33
0
        public static void Ctor_IEnumerable_HashSet_Multiple_Neg()
        {
            var           items  = new[] { 1, 2, 3, 4, 5 };
            HashSet <int> source = new HashSet <int>(items);

            HashSet <int>            hashSet = new HashSet <int>(source);
            HashSetTestSupport <int> driver  = new HashSetTestSupport <int>(hashSet, s_intGenerator, items);

            driver.VerifyHashSet_NegativeTests();
        }
 public static void Ctor_IEnumerable_Multiple()
 {
     int[] items = new int[] { -23, -2, 4, 6, 0, 123, -4 };
     HashSet<int> hashSet = new HashSet<int>(items);
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
     driver.VerifyHashSetTests();
 }
 public static void Ctor_IEnumerable_Duplicate()
 {
     int[] items = new int[] { 4, -23, -23, -2, 4, 6, 0, 4, 123, -4, 123 };
     HashSet<int> hashSet = new HashSet<int>(items);
     int[] expected = new int[] { -23, -2, 4, 6, 0, 123, -4 };
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, expected);
     driver.VerifyHashSetTests();
 }
 public static void Ctor_IEnumerable_Duplicate_Neg()
 {
     int[] items = new int[] { 4, -23, -23, -2, 4, 6, 0, 4, 123, -4, 123 };
     HashSet<int> hashSet = new HashSet<int>(items);
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
     driver.VerifyHashSet_NegativeTests();
 }
 public static void HashSetConstructor_IEn_IEq_Comparer_Null()
 {
     IEqualityComparer<int> nullComparer = null;
     HashSet<int> hashSet = new HashSet<int>(new int[] { -2, -3, -4, 0, 5 }, nullComparer);
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, new int[] { -2, -3, -4, 0, 5 });
     driver.VerifyHashSetTests();
 }
 public static void HashSetConstructor_IEqualityComparer_NotIEquatable()
 {
     IEqualityComparer<Item> defaultComparer = EqualityComparer<Item>.Default;
     HashSet<Item> hashSet = new HashSet<Item>(defaultComparer);
     Item[] items = new Item[0];
     HashSetTestSupport<Item> driver = new HashSetTestSupport<Item>(hashSet, Item.GenerateNext, items, defaultComparer);
 }
 public static void HashSetConstructor_IEn_IEq_IEnumerable_Empty()
 {
     int[] items = new int[0];
     HashSet<int> hashSet = new HashSet<int>(items, EqualityComparer<int>.Default);
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
     driver.VerifyHashSetTests();
 }
        public static void Ctor_IEnumerable_HashSet_Multiple_Neg()
        {
            var items = new[] { 1, 2, 3, 4, 5 };
            HashSet<int> source = new HashSet<int>(items);

            HashSet<int> hashSet = new HashSet<int>(source);
            HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
            driver.VerifyHashSet_NegativeTests();
        }
 public static void HashSetConstructor_IEn_IEq_IEnumerable_Duplicate()
 {
     HashSet<int> hashSet = new HashSet<int>(new int[] { 4, -23, -23, -2, 4, 6, 0, 4, 123, -4, 123 }, EqualityComparer<int>.Default);
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, new int[] { -23, -2, 4, 6, 0, 123, -4 });
     driver.VerifyHashSetTests();
 }
 public static void Ctor_IEnumerable_Single_Neg()
 {
     int[] items = new int[] { -23 };
     HashSet<int> hashSet = new HashSet<int>(items);
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
     driver.VerifyHashSet_NegativeTests();
 }
        public static void Ctor_IEnumerable_HashSet_Empty_Neg()
        {
            var items = new int[0];
            HashSet<int> source = new HashSet<int>(items);

            HashSet<int> hashSet = new HashSet<int>(source);
            HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
            driver.VerifyHashSet_NegativeTests();
        }
 public static void HashSetConstructor_IEn_IEq_Comparer_Default()
 {
     IEqualityComparer<ValueItem> defaultComparer = EqualityComparer<ValueItem>.Default;
     ValueItem[] items = new ValueItem[] { new ValueItem(1, -1), new ValueItem(2, -2), new ValueItem(3, -3), new ValueItem(4, -4) };
     HashSet<ValueItem> hashSet = new HashSet<ValueItem>(items, defaultComparer);
     HashSetTestSupport<ValueItem> driver = new HashSetTestSupport<ValueItem>(hashSet, ValueItem.GenerateNext, items, defaultComparer);
     driver.VerifyHashSetTests();
 }
 public static void HashSetConstructor_IEn_IEq_Comparer_Custom()
 {
     Item[] items = new Item[] { new Item(1), new Item(2), new Item(3), new Item(4) };
     IEqualityComparer<Item> comparer = new ItemEqualityComparer();
     HashSet<Item> hashSet = new HashSet<Item>(items, comparer);
     HashSetTestSupport<Item> driver = new HashSetTestSupport<Item>(hashSet, Item.GenerateNext, items, comparer);
     driver.VerifyHashSetTests();
 }
 public static void Ctor_IEnumerable_empty()
 {
     int[] items = new int[0];
     HashSet<int> hashSet = new HashSet<int>(items);
     HashSetTestSupport<int> driver = new HashSetTestSupport<int>(hashSet, s_intGenerator, items);
     driver.VerifyHashSetTests();
 }
 public static void HashSetConstructor_IEn_IEq_Comparer_NotIEquatable()
 {
     IEqualityComparer<Item> defaultComparer = EqualityComparer<Item>.Default;
     Item[] items = new Item[] { new Item(1), new Item(2), new Item(3), new Item(4) };
     HashSet<Item> hashSet = new HashSet<Item>(items, defaultComparer);
     HashSetTestSupport<Item> driver = new HashSetTestSupport<Item>(hashSet, Item.GenerateNext, items, defaultComparer);
     driver.VerifyHashSetTests();
 }