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 CanUseSameKeyAndValueTypes()
        {
            const string DOG   = "Dog";
            const string HORSE = "Horse";
            const string PET   = "Pet";
            const string FOOD  = "Food";

            PairDictionary <string, string> test = new PairDictionary <string, string>()
            {
                { DOG, PET },
                { HORSE, FOOD }
            };


            // NOTE: This syntax won't work because of ambiguity.
            // Uncomment it and try it out.
            // string val = test[DOG];


            // Make sure that the value associations will work.
            Assert.AreEqual(PET, test.Value(DOG));
            Assert.AreEqual(FOOD, test.Value(HORSE));

            // Make sure the key associations works.
            Assert.AreEqual(DOG, test.Key(PET));
            Assert.AreEqual(HORSE, test.Key(FOOD));
        }
        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);
        }
        // --------------------------------------------------------------------------------------------------------------------------
        public InspectionReport CompareObjects(Type type, object source, object comp, bool throwOnFail = false)
        {
            CachedReports = new MultiDictionary <object, object, InspectionReport>();
            SrcRefCache   = new PairDictionary <object, int>();
            CompRefCache  = new PairDictionary <object, int>();

            InspectionReport res = InternalCompare(type, source, comp, null, throwOnFail);

            // Cleanup and return...
            CachedReports.Clear();
            CachedReports = null;

            return(res);
        }
        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]);
        }
        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 ObjectInspector()
 {
     CachedReports = new MultiDictionary <object, object, InspectionReport>();
     SrcRefCache   = new PairDictionary <object, int>();
     CompRefCache  = new PairDictionary <object, int>();
 }