Example #1
0
        public void TestAddDuplicate()
        {
            var dict = new TwoKeyDictionary <string, int, string>();

            dict.Add("aaa", 0, "test");
            dict.Add("aaa", 0, "oops");
        }
Example #2
0
        public void TwoKeyDictionary_TwoKeyDictionary()
        {
            PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary();
            TwoKeyDictionary <string, int, int> seeder = ptkd.GetLoadedTwoKeyDictionary(POPSIZE);
            TwoKeyDictionary <string, int, int> tkd    = new TwoKeyDictionary <string, int, int>(seeder, null, null);

            Assert.AreEqual(11, tkd.Count, "main.Coun");
            Assert.AreEqual(11, tkd.AKeys.Count, "main.AKeys.Count");
            Assert.AreEqual(11, tkd.BKeys.Count, "main.BKeys.Count");
            Assert.AreEqual(11, tkd.Values.Count, "main.Values.Count");

            tkd.Add(ptkd.kavalues[11], ptkd.kbvalues[11], ptkd.vvalues[11]);
            tkd.Add(ptkd.kavalues[12], ptkd.kbvalues[12], ptkd.vvalues[12]);

            Assert.AreEqual(13, tkd.Count);
            Assert.AreEqual(13, tkd.AKeys.Count);
            Assert.AreEqual(13, tkd.BKeys.Count);
            Assert.AreEqual(13, tkd.Values.Count);

            int result = -1;

            result = tkd["AbaloneShell"];
            Assert.AreEqual(-2373699, result);

            result = tkd[12];
            Assert.AreEqual(-2373699, unchecked ((int)0xFFDBC7BD));
        }
Example #3
0
        public void TwoKeyDictionary_Capacity_IEqualityComparerAB()
        {
            PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary();
            TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>(13, StringComparer.CurrentCultureIgnoreCase, new IntEqualityComparer());

            for (int i = 0; i < 11; i++)
            {
                tkd.Add(ptkd.kavalues[i], ptkd.kbvalues[i], ptkd.vvalues[i]);
            }

            Assert.AreEqual(11, tkd.Count, "main.Coun");
            Assert.AreEqual(11, tkd.AKeys.Count, "main.AKeys.Count");
            Assert.AreEqual(11, tkd.BKeys.Count, "main.BKeys.Count");
            Assert.AreEqual(11, tkd.Values.Count, "main.Values.Count");

            tkd.Add(ptkd.kavalues[11], ptkd.kbvalues[11], ptkd.vvalues[11]);
            tkd.Add(ptkd.kavalues[12], ptkd.kbvalues[12], ptkd.vvalues[12]);

            Assert.AreEqual(13, tkd.Count);
            Assert.AreEqual(13, tkd.AKeys.Count);
            Assert.AreEqual(13, tkd.BKeys.Count);
            Assert.AreEqual(13, tkd.Values.Count);

            int result = -1;

            result = tkd["ABALONESHELL"];
            Assert.AreEqual(-2373699, result);

            result = tkd[12];
            Assert.AreEqual(-2373699, unchecked ((int)0xFFDBC7BD));
        }
Example #4
0
        public void Contains_TwoKeyValueTriple()
        {
            List <TwoKeyValueTriple <string, int, int> > items = new List <TwoKeyValueTriple <string, int, int> >();
            PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary();

            for (int i = 0; i < POPSIZE; i++)
            {
                TwoKeyValueTriple <string, int, int> tkv = new TwoKeyValueTriple <string, int, int>(ptkd.kavalues[i], ptkd.kbvalues[i], ptkd.vvalues[i]);
                items.Add(tkv);
            }

            TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>();

            for (int i = 0; i < items.Count; i++)
            {
                tkd.Add(items[i]);
            }

            for (int i = 0; i < POPSIZE; i++)
            {
                if (!tkd.Contains(items[i]))
                {
                    Assert.Fail();
                }
            }

            Assert.Pass();
        }
Example #5
0
        public void SerializationCheck()
        {
            TwoKeyDictionary <int, string, string> tkd = new TwoKeyDictionary <int, string, string>();

            // load it up
            tkd.Add(33024, "LJ02-026XN-PEP2F-M88L", "7FwCTLnD0ZdnDmYRPbZW");
            tkd.Add(66571, "LJ02-026XN-PEP2F-M88N", "Y4cE253SCT3agPC96Fhd");
            tkd.Add(86280, "LJ02-026XN-PEP2F-M88T", "cGnsZLmKK8xKDQnCprKY");
            tkd.Add(58647, "LJ02-026XN-PEP2F-M88R", "TWAggDF0jZVH454RRvrs");
            tkd.Add(87303, "LJ02-026XN-PEP2F-M88Q", "TuGEgtXSm9WQ6JLFGGLW");
            tkd.Add(86891, "LJ02-026XN-PEP2F-M88P", "ExmwnpRHWWx39dEkP6Ay");
            tkd.Add(69992, "LJ02-026XN-PEP2F-M88M", "cQ6RNcQcEm1KFXqRkBth");

            BinaryFormatter bf = new BinaryFormatter();

            byte[] serializeA;
            byte[] serializeB;

            serializeA = ObjectToByteArray(tkd);
            serializeB = ObjectToByteArray(tkd);

            Object deserializeA = ByteArrayToObject(serializeA);
            Object deserializeB = ByteArrayToObject(serializeB);

            bool result = false;

            result = CompairStringDictionary(((TwoKeyDictionary <int, string, string>)deserializeA), tkd);
            Assert.AreEqual(true, result);

            result = CompairStringDictionary(((TwoKeyDictionary <int, string, string>)deserializeB), tkd);
            Assert.AreEqual(true, result);
        }
Example #6
0
        public void TwoKeyDictionary_TwoKeyDictionary_IEqualityComparerAB()
        {
            PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary();
            TwoKeyDictionary <string, int, int> seeder = ptkd.GetLoadedTwoKeyDictionary(POPSIZE);
            TwoKeyDictionary <string, int, int> tkd    = new TwoKeyDictionary <string, int, int>(seeder, StringComparer.CurrentCultureIgnoreCase, new IntEqualityComparer());

            Assert.AreEqual(11, tkd.Count, "main.Coun");
            Assert.AreEqual(11, tkd.AKeys.Count, "main.AKeys.Count");
            Assert.AreEqual(11, tkd.BKeys.Count, "main.BKeys.Count");
            Assert.AreEqual(11, tkd.Values.Count, "main.Values.Count");

            tkd.Add(ptkd.kavalues[11], ptkd.kbvalues[11], ptkd.vvalues[11]);
            tkd.Add(ptkd.kavalues[12], ptkd.kbvalues[12], ptkd.vvalues[12]);

            Assert.AreEqual(13, tkd.Count);
            Assert.AreEqual(13, tkd.AKeys.Count);
            Assert.AreEqual(13, tkd.BKeys.Count);
            Assert.AreEqual(13, tkd.Values.Count);
        }
Example #7
0
        public TwoKeyDictionary <string, int, int> GetLoadedTwoKeyDictionary(int size)
        {
            TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>();

            for (int i = 0; i < size; i++)
            {
                tkd.Add(kavalues[i], kbvalues[i], vvalues[i]);
            }

            return(tkd);
        }
Example #8
0
        private static TwoKeyDictionary <string, int, string> CreateDict()
        {
            TwoKeyDictionary <string, int, string> dict = new TwoKeyDictionary <string, int, string>();

            dict.Add("aaa", 0, "x");
            dict.Add("aaa", 1, "y");
            dict.Add("aaa", 2, "z");

            dict.Add("bbb", 0, "test 1");
            dict.Add("bbb", 10, "test 2");
            dict.Add("bbb", 20, "test 3");
            dict.Add("bbb", 30, "test 4");

            dict.Add("ccc", -5, "");
            dict.Add("", 0, "");

            return(dict);
        }
Example #9
0
 private void setup()
 {
     Locations    = new TwoKeyDictionary <string, string, string>();
     config_files = collectConfigFiles();
     foreach (String user in config_files.Keys)
     {
         IniFileHandler ini = new IniFileHandler(config_files[user]);
         foreach (string section in ini.Keys)
         {
             if (ini[section].ContainsKey("savepath"))
             {
                 Locations.Add(user, section, ini[section]["savepath"]);
             }
         }
     }
     install_path = findInstallPath();
 }
Example #10
0
        public void Add_TwoKeyValueTriple()
        {
            List <TwoKeyValueTriple <string, int, int> > items = new List <TwoKeyValueTriple <string, int, int> >();
            PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary();

            for (int i = 0; i < POPSIZE; i++)
            {
                TwoKeyValueTriple <string, int, int> tkv = new TwoKeyValueTriple <string, int, int>(ptkd.kavalues[i], ptkd.kbvalues[i], ptkd.vvalues[i]);
                items.Add(tkv);
            }

            TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>();

            for (int i = 0; i < items.Count; i++)
            {
                tkd.Add(items[i]);
            }

            Assert.AreEqual(items.Count, tkd.Count);
        }
Example #11
0
        public void SyncRoot()
        {
            TwoKeyDictionary <string, int, int> stkd = sptkd.GetLoadedTwoKeyDictionary(POPSIZE);

            _items = stkd.BKeys;

            lock (stkd.SyncRoot)
            {
                stkd.Add(sptkd.kavalues[12], sptkd.kbvalues[12], sptkd.vvalues[12]);
                foreach (int item in _items)
                {
                    Console.WriteLine("main thread  " + item);
                    _result.Add("main thread  " + item);
                }
            }


            Assert.AreEqual(12, _result.Count);
            Assert.AreEqual("main thread  0", _result[0]);
            Assert.AreEqual("main thread  12", _result[11]);
        }
Example #12
0
        public void Add_Object()
        {
            List <Object[]>      items = new List <Object[]>();
            PackTwoKeyDictionary ptkd  = new PackTwoKeyDictionary();

            for (int i = 0; i < POPSIZE; i++)
            {
                object[] obj = new object[3];
                obj[0] = ptkd.kavalues[i];
                obj[1] = ptkd.kbvalues[i];
                obj[2] = ptkd.vvalues[i];
                items.Add(obj);
            }

            TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>();

            for (int i = 0; i < items.Count; i++)
            {
                tkd.Add(items[i][0], items[i][1], items[i][2]);
            }

            Assert.AreEqual(items.Count, tkd.Count);
        }
 private void setup()
 {
     Locations = new TwoKeyDictionary<string, string, string>();
     config_files = collectConfigFiles();
     foreach (String user in config_files.Keys) {
         IniFileHandler ini = new IniFileHandler(config_files[user]);
         foreach (string section in ini.Keys) {
             if (ini[section].ContainsKey("savepath")) {
                 Locations.Add(user, section, ini[section]["savepath"]);
             }
         }
     }
     install_path = findInstallPath();
 }