Exemplo n.º 1
0
        public void ChanceFalseSearch()
        {
            ReadFile      file  = new ReadFile();
            List <String> words = file.ReadWordsList("word list.txt");

            Bitmap      bitmap  = InsertWordsListInBitmap(words);
            WordChecker checker = new WordChecker(bitmap);

            StringBuilder word             = new StringBuilder();
            Int32         searchWordsCount = 0;

            for (Int32 count = 0; count < 1000000; count++)
            {
                for (Int32 numberChar = 0; numberChar < 4; numberChar++)
                {
                    Random random      = new Random();
                    Char   randomValue = (Char)random.Next(65, 122);
                    word.Append(randomValue);
                }

                if (checker.IsWordInBitmap(word.ToString()) == true)
                {
                    searchWordsCount++;
                }

                word.Clear();
            }

            Console.WriteLine(searchWordsCount);
        }
Exemplo n.º 2
0
        public void CheckOnExistAllWordsInBitmap()
        {
            ReadFile      file  = new ReadFile();
            List <String> words = file.ReadWordsList("word list.txt");

            Bitmap      bitmap  = InsertWordsListInBitmap(words);
            WordChecker checker = new WordChecker(bitmap);

            foreach (String word in words)
            {
                Assert.AreEqual(true, checker.IsWordInBitmap(word));
            }
        }
Exemplo n.º 3
0
        public void ElementIsInBitmap()
        {
            String testString = "Andrey";

            CalculationHash calculationHash = new CalculationHash();
            Bitmap          bitmap          = new Bitmap(32);

            Int32 md5Hash      = calculationHash.MD5CalculationValue(testString);
            Int32 sha1Hash     = calculationHash.SHA1CalculationValue(testString);
            Int32 standartHash = calculationHash.StandartHashCalculationValue(testString);

            bitmap.InsertHash(md5Hash);
            bitmap.InsertHash(sha1Hash);
            bitmap.InsertHash(standartHash);

            WordChecker wordChecker   = new WordChecker(bitmap);
            Boolean     returnedValue = wordChecker.IsWordInBitmap("Andrey");

            Assert.AreEqual(true, returnedValue);
        }