コード例 #1
0
ファイル: WhenCounting.cs プロジェクト: zish82/WordCounter
        public void CounterServiceReturnsCountedWords(string sentence, ObservableCollection<WordCountViewModel> expectedResult)
        {
            var searcher = new WordsCounterService();
            var countedWords = new ObservableCollection<WordCountViewModel>();

            searcher.Count(sentence, countedWords);

            Assert.That(countedWords.Count, Is.EqualTo(expectedResult.Count));
            Assert.IsTrue(expectedResult.All(x => Contains(countedWords, x)));
        }
コード例 #2
0
ファイル: WhenCounting.cs プロジェクト: zish82/WordCounter
        public void EmptySearchReturnsNoResult()
        {
            const string sentence = "";
            var counter = new WordsCounterService();
            var countedWords = new ObservableCollection<WordCountViewModel>();

            counter.Count(sentence, countedWords);

            Assert.IsEmpty(countedWords);
        }
コード例 #3
0
ファイル: WhenCounting.cs プロジェクト: zish82/WordCounter
        public void SentencesSplitOnSpecialCharacters(string specialCharacter)
        {
            var sentence = string.Format("firstPart{0}secondPart", specialCharacter);
            var counter = new WordsCounterService();
            var countedWords = new ObservableCollection<WordCountViewModel>();
            var wordCountViewModels = new ObservableCollection<WordCountViewModel> { new WordCountViewModel { Word = "firstPart", Count = 1 }, new WordCountViewModel { Word = "secondPart", Count = 1 } };

            counter.Count(sentence, countedWords);

            Assert.That(countedWords.All(x => Contains(wordCountViewModels, x)));
        }