Пример #1
0
 public void Eliminate_anagrams_with_same_checksum()
 {
     var detector = new Anagram("mass");
     var words = new[] { "last" };
     var results = new string[0];
     Assert.Equal(detector.Match(words), results);
 }
Пример #2
0
 public void Does_not_confuse_different_duplicates()
 {
     var detector = new Anagram("galea");
     var words = new[] { "eagle" };
     var results = new string[0];
     Assert.Equal(detector.Match(words), results);
 }
Пример #3
0
 public void Detect_simple_anagram()
 {
     var detector = new Anagram("ant");
     var words = new[] { "tan", "stand", "at" };
     var results = new[] { "tan" };
     Assert.That(detector.Match(words), Is.EquivalentTo(results));
 }
Пример #4
0
 public void Eliminate_anagram_subsets()
 {
     var detector = new Anagram("good");
     var words = new[] { "dog", "goody" };
     var results = new string[0];
     Assert.Equal(detector.Match(words), results);
 }
Пример #5
0
 public void No_matches()
 {
     var detector = new Anagram("diaper");
     var words = new[] { "hello", "world", "zombies", "pants" };
     var results = new string[0];
     Assert.Equal(detector.Match(words), results);
 }
Пример #6
0
 public void Detect_multiple_anagrams()
 {
     var detector = new Anagram("master");
     var words = new[] { "stream", "pigeon", "maters" };
     var results = new[] { "maters", "stream" };
     Assert.Equal(detector.Match(words), results);
 }
Пример #7
0
 public void Detect_simple_anagram()
 {
     var detector = new Anagram("ant");
     var words = new[] { "tan", "stand", "at" };
     var results = new[] { "tan" };
     Assert.Equal(detector.Match(words), results);
 }
Пример #8
0
        public void Constructor_WordAsParameter_WordAdded()
        {
            String word = "вертикаль";
            var anagram = new Anagram(word);

            Assert.IsTrue(anagram.Count() == 1 && anagram.Contains(word));
        }
Пример #9
0
 public void Identical_word_is_not_anagram()
 {
     var detector = new Anagram("corn");
     var words = new[] { "corn", "dark", "Corn", "rank", "CORN", "cron", "park" };
     var results = new[] { "cron" };
     Assert.Equal(detector.Match(words), results);
 }
Пример #10
0
        public void Constructor_WordAsParameter_KeyDefined()
        {
            String word = "вертикаль";
            var anagram = new Anagram(word);

            Assert.AreEqual(anagram.Key, Anagram.CreateKey(word));
        }
Пример #11
0
 public void Anagrams_are_case_insensitive()
 {
     var detector = new Anagram("Orchestra");
     var words = new[] { "cashregister", "Carthorse", "radishes" };
     var results = new[] { "Carthorse" };
     Assert.Equal(detector.Match(words), results);
 }
Пример #12
0
 public void Detect_anagrams()
 {
     var detector = new Anagram("allergy");
     var words = new[] { "gallery", "ballerina", "regally", "clergy", "largely", "leading" };
     var results = new[] { "gallery", "largely", "regally" };
     Assert.Equal(detector.Match(words), results);
 }
Пример #13
0
        public ActionResult Output(string word, string words)
        {
            Anagram myLetterVariable = new Anagram(word, words);

            myLetterVariable.SetWord(word);
            myLetterVariable.SetWords(words);
            return(View(myLetterVariable));
        }
Пример #14
0
    public void Anagrams_are_case_insensitive()
    {
        var detector = new Anagram("Orchestra");
        var words    = new[] { "cashregister", "Carthorse", "radishes" };
        var results  = new[] { "Carthorse" };

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #15
0
    public void Eliminate_anagram_subsets()
    {
        var detector = new Anagram("good");
        var words    = new[] { "dog", "goody" };
        var results  = new string[0];

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #16
0
    public void No_matches()
    {
        var detector = new Anagram("diaper");
        var words    = new[] { "hello", "world", "zombies", "pants" };
        var results  = new string[0];

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #17
0
    public void Detects_two_anagrams()
    {
        var candidates = new[] { "stream", "pigeon", "maters" };
        var sut        = new Anagram("master");
        var expected   = new[] { "stream", "maters" };

        Assert.Equal(expected, sut.FindAnagrams(candidates));
    }
Пример #18
0
    public void Does_not_confuse_different_duplicates()
    {
        var detector = new Anagram("galea");
        var words    = new[] { "eagle" };
        var results  = new string[0];

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #19
0
    public void Detect_multiple_anagrams()
    {
        var detector = new Anagram("master");
        var words    = new[] { "stream", "pigeon", "maters" };
        var results  = new[] { "maters", "stream" };

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #20
0
    public void Detect_simple_anagram()
    {
        var detector = new Anagram("ant");
        var words    = new[] { "tan", "stand", "at" };
        var results  = new[] { "tan" };

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #21
0
    public void Detects_anagrams_using_case_insensitive_possible_matches()
    {
        var candidates = new[] { "cashregister", "Carthorse", "radishes" };
        var sut        = new Anagram("orchestra");
        var expected   = new[] { "Carthorse" };

        Assert.Equal(expected, sut.FindAnagrams(candidates));
    }
Пример #22
0
    public void Detects_multiple_anagrams_with_different_case()
    {
        var candidates = new[] { "Eons", "ONES" };
        var sut        = new Anagram("nose");
        var expected   = new[] { "Eons", "ONES" };

        Assert.Equal(expected, sut.FindAnagrams(candidates));
    }
Пример #23
0
    public void Detects_three_anagrams()
    {
        var candidates = new[] { "gallery", "ballerina", "regally", "clergy", "largely", "leading" };
        var sut        = new Anagram("allergy");
        var expected   = new[] { "gallery", "regally", "largely" };

        Assert.Equal(expected, sut.FindAnagrams(candidates));
    }
Пример #24
0
    public void Detects_anagram()
    {
        var candidates = new[] { "enlists", "google", "inlets", "banana" };
        var sut        = new Anagram("listen");
        var expected   = new[] { "inlets" };

        Assert.Equal(expected, sut.FindAnagrams(candidates));
    }
Пример #25
0
        // GET: Anagram
        //public ActionResult Search()
        //{
        //    var anagram = new Anagram();
        //    anagram.FindSecretPhrase("poultry outwits ants", "4624d200580677270a54ccff86b9610e");
        //    return View(anagram);
        //}

        public ActionResult Search(string hintPhrase, string md5HashKey)
        {
            var anagram = new Anagram();

            //anagram.FindSecretPhrase(hintPhrase, md5HashKey);
            anagram.FindSecretPhrase("poultry outwits ants", "4624d200580677270a54ccff86b9610e");
            return(View(anagram));
        }
Пример #26
0
    public void Detects_anagrams_case_insensitively()
    {
        var candidates = new[] { "cashregister", "Carthorse", "radishes" };
        var sut        = new Anagram("Orchestra");
        var expected   = new[] { "Carthorse" };

        Assert.Equal(expected, sut.Anagrams(candidates));
    }
Пример #27
0
    public void Detects_simple_anagram()
    {
        var candidates = new[] { "tan", "stand", "at" };
        var sut        = new Anagram("ant");
        var expected   = new[] { "tan" };

        Assert.Equal(expected, sut.Anagrams(candidates));
    }
Пример #28
0
    public void Words_other_than_themselves_can_be_anagrams()
    {
        var candidates = new[] { "Listen", "Silent", "LISTEN" };
        var sut        = new Anagram("LISTEN");
        var expected   = new[] { "Silent" };

        Assert.Equal(expected, sut.FindAnagrams(candidates));
    }
Пример #29
0
        public void GetSetWordToCompare_SetsWordToCompare_String()
        {
            Anagram testAnagram = new Anagram();
            string  word        = "test";

            testAnagram.SetWordToCompare(word);
            Assert.AreEqual(word, testAnagram.GetWordToCompare());
        }
Пример #30
0
    public void Does_not_detect_identical_words()
    {
        var candidates = new[] { "corn", "dark", "Corn", "rank", "CORN", "cron", "park" };
        var sut        = new Anagram("corn");
        var expected   = new[] { "cron" };

        Assert.Equal(expected, sut.Anagrams(candidates));
    }
Пример #31
0
    public void Eliminate_anagrams_with_same_checksum()
    {
        var detector = new Anagram("mass");
        var words    = new[] { "last" };
        var results  = new string[0];

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #32
0
        public void CharactersInWord_WordTurnedIntoCharArray_CharArray()
        {
            Anagram testAnagram = new Anagram();
            string  word        = "noob";

            char[] wordSplit = { 'n', 'o', 'o', 'b' };
            CollectionAssert.AreEqual(wordSplit, testAnagram.CharactersInWord(word));
        }
Пример #33
0
    public void Identical_word_is_not_anagram()
    {
        var detector = new Anagram("corn");
        var words    = new[] { "corn", "dark", "Corn", "rank", "CORN", "cron", "park" };
        var results  = new[] { "cron" };

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #34
0
        public void GetSetWordMatches_GetsSetsWordMatches_String()
        {
            Anagram testAnagram = new Anagram();
            string  word        = "test";

            testAnagram.SetWordMatches(word);
            Assert.AreEqual(word, testAnagram.GetWordMatches()[0]);
        }
Пример #35
0
    public void Detect_anagrams()
    {
        var detector = new Anagram("allergy");
        var words    = new[] { "gallery", "ballerina", "regally", "clergy", "largely", "leading" };
        var results  = new[] { "gallery", "largely", "regally" };

        Assert.That(detector.Match(words), Is.EquivalentTo(results));
    }
Пример #36
0
        public void IsWords_Sorted()
        {
            //Arrange
            string word2 = "aaasnm";
            string name  = "manasa";

            Assert.AreEqual("IsAnagram", Anagram.IsAnagram(name, word2));
        }
Пример #37
0
        public void TryAdd_ExistingAnagram_FalseReturned()
        {
            String word = "вертикаль";
            var anagram = new Anagram(word);

            Boolean value = anagram.TryAdd(word);

            Assert.IsFalse(value);
        }
Пример #38
0
        public void IsAnagram_SingleWord_FalseReturned()
        {
            String word = "вертикаль";
            var anagram = new Anagram(word);

            Boolean value = anagram.IsAnagram;

            Assert.IsFalse(value);
        }
Пример #39
0
        public void GetWord_ReturnsWord_String()
        {
            string  word    = "dear";
            Anagram anagram = new Anagram(word);

            string result = Anagram.Word;

            Assert.AreEqual(word, result);
        }
 public IActionResult CheckAnagram([FromBody] Anagram a)
 {
     reader.ReadFile(configuration["dictonaryFileName"]);
     if (AnagramLibrary.AnagramLibrary.CheckToWords(a.W1, a.W2))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Пример #41
0
        public void AddAnagram_AddsWordsToMatchList_String()
        {
            Anagram testAnagram = new Anagram();
            string  word        = "gandalf";

            testAnagram.SetWordToCompare(word);
            testAnagram.AddAnagram();
            Assert.AreEqual(word, testAnagram.GetWordMatches()[0]);
        }
Пример #42
0
        public void SortAndReturnWord_CharsAreSortedAndReturned_CharArray()
        {
            Anagram testAnagram = new Anagram();
            string  word        = "frodo";

            char[] splitWord = word.ToCharArray();
            Array.Sort(splitWord);
            CollectionAssert.AreEqual(splitWord, testAnagram.SortAndReturnChars(word));
        }
Пример #43
0
        public void CheckLettersAreEqual_TestEachLetterIsEqual_True()
        {
            Anagram testAnagram = new Anagram();
            char    letterOne   = 'f';
            char    letterTwo   = 'f';

            testAnagram.CheckLettersAreEqual(letterOne, letterTwo);
            Assert.AreEqual(true, testAnagram.GetSameLetters());
        }
Пример #44
0
        public List <char []> getAllAnagrams(string initial)
        {
            Stack <char> stack   = new Stack <char>();
            Anagram      anagram = new Anagram();

            composeAnagrams(initial, stack, anagram);

            return(anagrams);
        }
Пример #45
0
        public void IsAnagram_MultipleWords_TrueReturned()
        {
            String word = "вертикаль", wordToAdd = "кильватер";
            var anagram = new Anagram(word);
            anagram.TryAdd(wordToAdd);

            Boolean value = anagram.IsAnagram;

            Assert.IsTrue(value);
        }
        public void ConfirmAreAnagrams()
        {
            var careWord = new Anagram("CARE");
            var raceWord = new Anagram("RACE");

            careWord.Key.Should().Be("ACER");
            raceWord.Key.Should().Be("ACER");

            var areAnagrams = AreAnagrams(careWord, raceWord);
            areAnagrams.Should().BeTrue();
        }
Пример #47
0
        public void TryAdd_NotAnagram_FalseReturned()
        {
            String word = "вертикаль", wordToAdd = "король";
            var anagram = new Anagram(word);

            Boolean value = anagram.TryAdd(wordToAdd);

            Assert.IsFalse(value);
        }
Пример #48
0
        public void TryAdd_NewAnagram_AnagramAdded()
        {
            String word = "вертикаль", wordToAdd = "кильватер";
            var anagram = new Anagram(word);

            Boolean value = anagram.TryAdd(wordToAdd);

            Assert.IsTrue(anagram.Count() == 2 && anagram.Contains(word) && anagram.Contains(wordToAdd));
        }
Пример #49
0
        public void TryAdd_ExistingAnagram_NoChangesMade()
        {
            String word = "вертикаль";
            var anagram = new Anagram(word);

            Boolean value = anagram.TryAdd(word);

            Assert.IsTrue(anagram.Count() == 1 && anagram.Contains(word));
        }
 private static bool AreAnagrams(Anagram first, Anagram second)
 {
     return first.Key == second.Key && !string.IsNullOrEmpty(first.Key);
 }