public void Parse_NullAsSentencePassed_ThrowsArgumentNullException()
        {
            var splitterStub = MockRepository.GenerateStub<IStringSplitter>();
            var sp = new SentenceParser(splitterStub);

            Assert.Throws<ArgumentNullException>(() => sp.Parse(null));
        }
Example #2
0
        public Form1()
        {
            topicParser = new TopicsParser(repository);
            sentenceParser = new SentenceParser(repository);

            InitializeComponent();
        }
        public void TestTotalWordCount(string sentence, int expectedTotalUniqueWordCount)
        {
            SentenceParser sentenceParser = new SentenceParser();
            var results = sentenceParser.Parse(sentence);
            int actual = results.TotalUniqueWordCount;

            Assert.IsTrue(expectedTotalUniqueWordCount == actual, string.Format("Expected {0} but found {1}", expectedTotalUniqueWordCount, actual));
        }
        public void TestUniqueWords(string sentence, string uniqueWord, int uniqueWordExpectedCount)
        {
            SentenceParser sentenceParser = new SentenceParser();
            var results = sentenceParser.Parse(sentence);

            int actualCount = results[uniqueWord];

            Assert.IsTrue(actualCount == uniqueWordExpectedCount, string.Format("Expected {0} but found {1}", uniqueWordExpectedCount, actualCount));
        }
        public void Parse_ArbitrarySentencePassed_ReturnsWordsWithCount(Tuple<string[], Dictionary<string, int>> testCase)
        {
            var splitterStub = MockRepository.GenerateStub<IStringSplitter>();

            splitterStub.Stub(t => t.SplitIntoWords(Arg<string>.Is.Anything)).Return(testCase.Item1);

            var sp = new SentenceParser(splitterStub);

            var actualWordsCounts = sp.Parse("SOME DUMMY STRING");

            CollectionAssert.AreEquivalent(testCase.Item2, actualWordsCounts);
        }
 public void TestExceptionThrown(string sentence, string uniqueWord, int uniqueWordExpectedCount)
 {
     SentenceParser sentenceParser = new SentenceParser();
     sentenceParser.Parse(sentence);
 }