public void CantAddDuplicateValues()
        {
            PairDictionary <int, string> test = new PairDictionary <int, string>();

            const string DUPE = "ABC";

            test.Add(1, DUPE);

            // KABOOM!
            test.Add(2, DUPE);
        }
        public void CantAddDuplicateKeys()
        {
            PairDictionary <string, int> test = new PairDictionary <string, int>();

            const string DUPE = "ABC";

            test.Add(DUPE, 1);

            // KABOOM!
            test.Add(DUPE, 2);
        }
        // --------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Makes sure that the items in question match their graph position.
        /// The theory is that if the graphs are correct, then the order of the referenced items will also be the same.
        /// </summary>
        private bool CheckReferenceGraph(object source, object comp)
        {
            int srcID  = -1;
            int compID = -1;

            if (!SrcRefCache.ContainsKey(source))
            {
                srcID = SrcRefCache.Count;
                SrcRefCache.Add(source, srcID);
            }
            else
            {
                srcID = SrcRefCache[source];
            }


            if (!CompRefCache.ContainsKey(comp))
            {
                compID = CompRefCache.Count;
                CompRefCache.Add(comp, compID);
            }
            {
                compID = CompRefCache[comp];
            }

            // Do they match ??
            return(srcID == compID);
        }
        public void CanGetDictionaryKeysAndValues()
        {
            int[]    keys = new int[] { 1, 2, 3 };
            string[] vals = new string[] { "alpha", "beta", "gamma" };

            PairDictionary <int, string> test = new PairDictionary <int, string>();

            for (int i = 0; i < keys.Length; i++)
            {
                test.Add(keys[i], vals[i]);
            }

            Assert.AreEqual(keys.Length, test.Count);

            IList <int>    testKeys = test.Keys;
            IList <string> testVals = test.Values;

            Assert.AreEqual(test.Count, testKeys.Count);
            Assert.AreEqual(test.Count, testVals.Count);

            // Make sure that the contained keys / values are correct.
            for (int i = 0; i < keys.Length; i++)
            {
                Assert.AreEqual(keys[i], testKeys[i]);
                Assert.AreEqual(vals[i], testVals[i]);
            }
        }
        public void CanUseKeyComparer()
        {
            PairDictionary <string, int> test = new PairDictionary <string, int>(StringComparer.OrdinalIgnoreCase);

            test.Add(ONE, 1);
            test.Add(TWO, 2);
            test.Add(THREE, 3);

            // See, the formatting no longer matters.
            Assert.AreEqual(1, test[ONE.ToLower()]);
            Assert.AreEqual(2, test[TWO.ToUpper()]);
            Assert.AreEqual(3, test["tHreE"]);

            // TODO: Include a check to show that we will get an exception if we use odd formatting as well.
            // 'DrewCo.UnitTesting' ??
        }
        public void CanSetValuesViaKeys()
        {
            const string KEY   = "x";
            const int    VAL_1 = 100;
            const int    VAL_2 = 1000;

            PairDictionary <string, int> test = new PairDictionary <string, int>();

            test.Add(KEY, VAL_1);

            // Set the value, and make sure that it took!
            test[KEY] = VAL_2;
            Assert.AreEqual(VAL_2, test[KEY]);
        }