Example #1
0
        public void Clone(int count)
        {
            HashtableEx hash1 = Helpers.CreateStringHashtable(count);

            Helpers.PerformActionOnAllHashtableWrappers(hash1, hash2 =>
            {
                HashtableEx clone = (HashtableEx)hash2.Clone();

                Assert.AreEqual(hash2.Count, clone.Count);
                Assert.AreEqual(hash2.IsSynchronized, clone.IsSynchronized);
                Assert.AreEqual(hash2.IsFixedSize, clone.IsFixedSize);
                Assert.AreEqual(hash2.IsReadOnly, clone.IsReadOnly);

                for (int i = 0; i < clone.Count; i++)
                {
                    string key   = "Key_" + i;
                    string value = "Value_" + i;

                    Assert.IsTrue(clone.ContainsKey(key));
                    Assert.IsTrue(clone.ContainsValue(value));
                    Assert.AreEqual(value, clone[key]);
                }
            });
        }
Example #2
0
        public void AddRemove_LargeAmountNumbers()
        {
            // Generate a random 100,000 array of ints as test data
            var inputData = new int[100000];
            var random    = new Random(341553);

            for (int i = 0; i < inputData.Length; i++)
            {
                inputData[i] = random.Next(7500000, int.MaxValue);
            }

            var hash = new HashtableEx();

            int count = 0;

            foreach (long number in inputData)
            {
                hash.Add(number, count++);
            }

            count = 0;
            foreach (long number in inputData)
            {
                Assert.AreEqual(hash[number], count);
                Assert.IsTrue(hash.ContainsKey(number));

                count++;
            }

            foreach (long number in inputData)
            {
                hash.Remove(number);
            }

            Assert.AreEqual(0, hash.Count);
        }
Example #3
0
 internal bool ContainsKey(Type ownerType)
 => _table.ContainsKey(ownerType);