예제 #1
0
        public static void Ctor_IDictionary_Int_IEqualityComparer()
        {
            // No exception
            var hash1 = new ComparableHashtable(new Hashtable(), 1f, null);

            Assert.Equal(0, hash1.Count);

            hash1 = new ComparableHashtable(new Hashtable(new Hashtable(
                                                              new Hashtable(new Hashtable(new Hashtable(), 1f, null), 1f, null), 1f, null), 1f, null), 1f, null);
            Assert.Equal(0, hash1.Count);

            // Null comparer
            Hashtable hash2 = Helpers.CreateIntHashtable(100);

            hash1 = new ComparableHashtable(hash2, 1f, null);
            VerifyHashtable(hash1, hash2, null);

            hash2 = Helpers.CreateIntHashtable(100);
            // Custom comparer
            Helpers.PerformActionOnCustomCulture(() =>
            {
                IEqualityComparer comparer = StringComparer.CurrentCulture;
                hash1 = new ComparableHashtable(hash2, 1f, comparer);
                VerifyHashtable(hash1, hash2, comparer);
            });
        }
예제 #2
0
        public static void Ctor_IEqualityComparer()
        {
            // Null comparer
            var hash = new ComparableHashtable((IEqualityComparer)null);

            VerifyHashtable(hash, null, null);

            // Custom comparer
            Helpers.PerformActionOnCustomCulture(() =>
            {
                IEqualityComparer comparer = StringComparer.CurrentCulture;
                hash = new ComparableHashtable(comparer);
                VerifyHashtable(hash, null, comparer);
            });
        }
예제 #3
0
        public static void Ctor_Int_Int_IEqualityComparer(int capacity, float loadFactor)
        {
            // Null comparer
            var hash = new ComparableHashtable(capacity, loadFactor, null);

            VerifyHashtable(hash, null, null);
            Assert.Null(hash.EqualityComparer);

            // Custom comparer
            Helpers.PerformActionOnCustomCulture(() =>
            {
                IEqualityComparer comparer = StringComparer.CurrentCulture;
                hash = new ComparableHashtable(capacity, loadFactor, comparer);
                VerifyHashtable(hash, null, comparer);
            });
        }