public void AddRangeDuplicateInDictionary()
        {         //****************************************
            var MyRecords = new StringKeyDictionary <int>(64);

            //****************************************

            MyRecords["E"] = 1;
            MyRecords["F"] = 2;
            MyRecords["G"] = 3;
            MyRecords["H"] = 4;

            try
            {
                MyRecords.AddRange(new[] { new KeyValuePair <string, int>("A", 1), new KeyValuePair <string, int>("B", 2), new KeyValuePair <string, int>("C", 3), new KeyValuePair <string, int>("G", 4) });

                Assert.Fail("Range succeeded");
            }
            catch (ArgumentException)
            {
            }

            //****************************************

            Assert.AreEqual(4, MyRecords.Count, "Items were added");
        }
        public void AddRange()
        {         //****************************************
            var Random  = Initialise();
            var Records = new StringKeyDictionary <int>();

            var Dictionary = new Dictionary <string, int>(1024);

            //****************************************

            foreach (var Pair in YieldRandom(Random, 1024))
            {
                Dictionary.Add(Pair.Key, Pair.Value);
            }

            Records.AddRange(Dictionary);

            //****************************************

            Assert.AreEqual(1024, Records.Count, "Count incorrect");

            CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match");

            foreach (var MyPair in Dictionary)
            {
                Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value));
                Assert.AreEqual(MyPair.Value, Value);
            }

            Thread.Sleep(1);
        }
        public void AddRangePrePopulated()
        {         //****************************************
            var Random  = Initialise();
            var Records = new StringKeyDictionary <int>();

            var Dictionary = new Dictionary <string, int>(1024);
            var SecondSet  = new List <KeyValuePair <string, int> >(512);

            //****************************************

            foreach (var Pair in YieldRandom(Random, 1024))
            {
                Dictionary.Add(Pair.Key, Pair.Value);

                if (Records.Count < 512)
                {
                    Records.Add(Pair.Key, Pair.Value);
                }
                else
                {
                    SecondSet.Add(Pair);
                }
            }

            //****************************************

            Records.AddRange(SecondSet);

            //****************************************

            Assert.AreEqual(1024, Records.Count, "Count incorrect");

            CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match");

            foreach (var MyPair in Dictionary)
            {
                Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value));
                Assert.AreEqual(MyPair.Value, Value);
            }

            Thread.Sleep(1);
        }