private IBijectionDictionary <int, string> GenerateNewTestDictionary(int maxCount)
        {
            IBijectionDictionary <int, string> dict = new BijectionDictionaryImpl <int, string>();

            for (int i = 0; i < maxCount; i++)
            {
                dict.Add(i, GetTestStringBasedOnIndex(i));
            }
            return(dict);
        }
        public void TestGivenExistingDictionaryWhenWrappedInTwoWayDictionaryThenReverseVersionIsPopulated()
        {
            int maxCount = 10;
            IDictionary <int, string> dict = new Dictionary <int, string>();

            for (int i = 0; i < maxCount; i++)
            {
                dict.Add(i, GetTestStringBasedOnIndex(i));
            }

            Assert.AreEqual(maxCount, dict.Count, "GIVEN: Source dictionary has incorrect length");

            IBijectionDictionary <int, string> twoWayDict = new BijectionDictionaryImpl <int, string>(dict);

            Assert.AreEqual(maxCount, twoWayDict.Count, "Two way dictionary not populated correctly");
            Assert.AreEqual(maxCount, twoWayDict.Reverse.Count, "Reverse dictionary not populated correctly");

            AssertOriginalAndReversedVersionsMatchExactly(twoWayDict);
        }
        public void TestGivenNonUniqueKeyValuePairsWhenAddedToTwoWayDictionaryThenExceptionsThrownForDuplicates()
        {
            IBijectionDictionary <int, string> dict = new BijectionDictionaryImpl <int, string>();

            dict.Add(0, GetTestStringBasedOnIndex(0));
            int countBefore = dict.Count;

            // Exception thrown for duplicate keys
            Assert.Throws <ArgumentException>(() => dict.Add(0, GetTestStringBasedOnIndex(0)));
            Assert.AreEqual(countBefore, dict.Count, "Item added to dictionary after exception thrown");
            Assert.AreEqual(countBefore, dict.Reverse.Count, "Item added to reversed dictionary after exception thrown");

            // Exception thrown for duplicate values for unique keys
            Assert.Throws <ArgumentException>(() => dict.Add(1, GetTestStringBasedOnIndex(0)));
            Assert.AreEqual(countBefore, dict.Count, "Item added to dictionary after exception thrown");
            Assert.AreEqual(countBefore, dict.Reverse.Count, "Item added to reversed dictionary after exception thrown");

            // Add succeeds with unique key + value
            dict.Add(1, GetTestStringBasedOnIndex(1));
        }