예제 #1
0
        public void ValidPangramTooLong()
        {
            Pangram pangram = new Pangram();

            Assert.AreEqual(pangram.IsPangram("We promptly judged antique ivory buckles for the prize" +
                                              "We promptly judged antique ivory buckles for the prize We promptly judged antique ivory buckles for the prize"), 0);
        }
예제 #2
0
        public void InValidPangramTooShort()
        {
            Pangram pangram = new Pangram();

            //Pass in nothing
            Assert.AreEqual(pangram.IsPangram(String.Empty), 0);
        }
예제 #3
0
        public void TestMethodMixnMatch()
        {
            //Arange
            var sentenceTest = "abcdeFghijKlmnopqrstuvWXYZ";
            //Act
            var isPangram = Pangram.PangramSolution(sentenceTest);

            //Assert
            Assert.AreEqual(isPangram, "pangram");
        }
예제 #4
0
        public void TestMethod3AllLower()
        {
            //Arange
            var sentenceTest = "abcdefghijklmnopqrstuvwxyz";
            //Act
            var isPangram = Pangram.PangramSolution(sentenceTest);

            //Assert
            Assert.AreEqual(isPangram, "pangram");
        }
예제 #5
0
        public void TestMethod2AllUpper()
        {
            //Arange
            var sentenceTest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            //Act
            var isPangram = Pangram.PangramSolution(sentenceTest);

            //Assert
            Assert.AreEqual(isPangram, "pangram");
        }
예제 #6
0
        public void TestMethod1()
        {
            //Arange
            var sentenceTest = "We promptly judged antique ivory buckles for the next prize";
            //Act
            var isPangram = Pangram.PangramSolution(sentenceTest);

            //Assert
            Assert.AreEqual(isPangram, "pangram");
        }
예제 #7
0
        public void LetterDictionaryLoadsWithAllLettersAndZeroCount()
        {
            Pangram pangram = new Pangram();

            var dictionary = pangram.LoadDictionary();

            // There are 26 letters in the dictionary
            Assert.AreEqual(dictionary.Count, 26);

            // For each letter we should have a count of zero
            foreach (var letterCount in dictionary)
            {
                Assert.AreEqual(letterCount.Value, 0);
            }
        }
예제 #8
0
    public static bool IsPangram(string input)
    {
        HashSet <char> uniqueLetters = new HashSet <char>();

        foreach (char c in input.ToLower())
        {
            if (Pangram.IsAlpha(c))
            {
                uniqueLetters.Add(c);
            }
        }

        if (uniqueLetters.Count == 26)
        {
            return(true);
        }

        return(false);
    }
예제 #9
0
 public void Case_insensitive()
 {
     Assert.False(Pangram.IsPangram("the quick brown fox jumps over with lazy FX"));
 }
예제 #10
0
 public void Missing_letters_replaced_by_numbers()
 {
     Assert.False(Pangram.IsPangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog"));
 }
예제 #11
0
 public void With_underscores()
 {
     Assert.True(Pangram.IsPangram("the_quick_brown_fox_jumps_over_the_lazy_dog"));
 }
예제 #12
0
 public void Missing_the_letter_x()
 {
     Assert.False(Pangram.IsPangram("a quick movement of the enemy will jeopardize five gunboats"));
 }
예제 #13
0
 public void Perfect_lower_case()
 {
     Assert.True(Pangram.IsPangram("abcdefghijklmnopqrstuvwxyz"));
 }
예제 #14
0
    public void Pangram_with_non_ascii_characters()
    {
        var input = "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(true));
    }
예제 #15
0
    public void Missing_letters_replaced_by_numbers()
    {
        var input = "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(false));
    }
예제 #16
0
    public void Empty_sentence()
    {
        var input = "";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(false));
    }
예제 #17
0
        public HttpResponseMessage PostPangram([FromBody]string sentence)
        {
            CreatePangramResponse createPangramResponse = new CreatePangramResponse();
            createPangramResponse.isPangram = false;
            IRepository<Pangram> _pangramRepo = new MongoRepository<Pangram>();

            if (!String.IsNullOrEmpty(sentence))
            {
                var pangram = new Pangram(sentence);
                if (pangram.isPangram)
                {
                    var pangrams = _pangramRepo.Select(p => p).ToList();
                    var checkForSamePangramInRepo = pangrams.AsEnumerable().Where(p => p.Sentence == sentence).Select(p => p.Sentence).ToList();
                    if (checkForSamePangramInRepo.Count() == 0)
                    {
                        _pangramRepo.Add(pangram);
                    }
                    createPangramResponse.isPangram = true;
                }
            }

            return new HttpResponseMessage()
            {
                Content = new JsonContent2(
                    createPangramResponse
                 )
            };
        }
예제 #18
0
    public void Pangram_with_mixed_case_and_punctuation()
    {
        var input = "\"Five quacking Zephyrs jolt my wax bed.\"";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(true));
    }
예제 #19
0
 public void Upper_and_lower_case_versions_of_the_same_character_should_not_be_counted_separately()
 {
     Assert.False(Pangram.IsPangram("the quick brown fox jumps over with lazy FX"));
 }
예제 #20
0
    public void Pangram_in_alphabet_other_than_ascii()
    {
        var input = "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(false));
    }
예제 #21
0
 public void Sentence_empty()
 {
     Assert.False(Pangram.IsPangram(""));
 }
예제 #22
0
 public void Only_lower_case()
 {
     Assert.True(Pangram.IsPangram("the quick brown fox jumps over the lazy dog"));
 }
예제 #23
0
    public void Pangram_with_only_lower_case()
    {
        var input = "the quick brown fox jumps over the lazy dog";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(true));
    }
예제 #24
0
 public void Missing_the_letter_h()
 {
     Assert.False(Pangram.IsPangram("five boxing wizards jump quickly at it"));
 }
예제 #25
0
    public void Missing_character_x()
    {
        var input = "a quick movement of the enemy will jeopardize five gunboats";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(false));
    }
예제 #26
0
 public void With_numbers()
 {
     Assert.True(Pangram.IsPangram("the 1 quick brown fox jumps over the 2 lazy dogs"));
 }
예제 #27
0
    public void Another_missing_character_x()
    {
        var input = "the quick brown fish jumps over the lazy dog";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(false));
    }
예제 #28
0
 public void Mixed_case_and_punctuation()
 {
     Assert.True(Pangram.IsPangram("\"Five quacking Zephyrs jolt my wax bed.\""));
 }
예제 #29
0
    public void Pangram_with_underscores()
    {
        var input = "the_quick_brown_fox_jumps_over_the_lazy_dog";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(true));
    }
예제 #30
0
 public void Empty_sentence()
 {
     Assert.False(Pangram.IsPangram(""));
 }
예제 #31
0
    public void Pangram_with_numbers()
    {
        var input = "the 1 quick brown fox jumps over the 2 lazy dogs";

        Assert.That(Pangram.IsPangram(input), Is.EqualTo(true));
    }