Exemplo n.º 1
0
        public bool CanCountWords(string stringText, bool isBusy)
        {
            var counter = new WordsCounterService();
            var viewModel = new MainViewModel(counter) {Sentence = stringText, IsBusy = isBusy};

            var countedWords = viewModel.CountWordsCommand;

            return countedWords.CanExecute(null);
        }
Exemplo n.º 2
0
        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)));
        }
Exemplo n.º 3
0
        public void EmptySearchReturnsNoResult()
        {
            const string sentence = "";
            var counter = new WordsCounterService();
            var countedWords = new ObservableCollection<WordCountViewModel>();

            counter.Count(sentence, countedWords);

            Assert.IsEmpty(countedWords);
        }
Exemplo n.º 4
0
        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)));
        }