Beispiel #1
0
        /**************************************************************************/

        public TestMacroscopeStringLookup()
        {
            MacroscopeStringLookup.Clear();

            Faker fake = new Faker();

            this.Texts           = new List <string>();
            this.RandomizedTexts = new Dictionary <string, bool>();

            for (int i = 0; i < this.MaxTexts; i++)
            {
                Texts.Add(fake.Lorem.Sentence());
            }

            this.DistinctTexts = Texts.Distinct().ToList();

            foreach (string Text in this.DistinctTexts)
            {
                this.RandomizedTexts.Add(Text, true);
            }
        }
Beispiel #2
0
        public void TestStringLookupWithClear()
        {
            for (int repeat = 0; repeat < this.MaxLoops; repeat++)
            {
                MacroscopeStringLookup.Clear();

                foreach (string Text in this.DistinctTexts)
                {
                    MacroscopeStringLookup.Lookup(Text: Text);
                }

                foreach (string Text in this.RandomizedTexts.Keys)
                {
                    ulong value     = MacroscopeStringLookup.Lookup(Text: Text);
                    ulong found     = 0;
                    bool  not_found = true;

                    for (int k = 0; k < this.DistinctTexts.Count(); k++)
                    {
                        if (this.DistinctTexts[k] == Text)
                        {
                            found     = (ulong)k;
                            not_found = false;
                            break;
                        }
                        else
                        {
                            not_found = true;
                        }
                    }

                    Assert.IsFalse(not_found);
                    Assert.AreEqual(value, found);
                }
            }
        }