Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 34
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();
 }
Ejemplo n.º 35
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();
 }
Ejemplo n.º 36
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();
 }
Ejemplo n.º 37
0
 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();
 }
Ejemplo n.º 38
0
 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);
 }
Ejemplo n.º 39
0
 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();
 }
Ejemplo n.º 40
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();
        }
Ejemplo n.º 41
0
 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();
 }
Ejemplo n.º 42
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();
 }
Ejemplo n.º 43
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();
        }
Ejemplo n.º 44
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();
 }
Ejemplo n.º 45
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();
 }
Ejemplo n.º 46
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();
 }
Ejemplo n.º 47
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();
 }