Ejemplo n.º 1
0
        public async Task InsertWordSuccessfullWhenAnagramDefinedAndNoDuplicatesFound()
        {
            var anagram = new Anagram()
            {
                Category = "cat", Word = "Word"
            };
            var entities = new List <WordEntity>()
            {
                new WordEntity()
                {
                    Word = "word1"
                }
            };

            _wordRepoMock.GetSelectedWordAnagrams(Arg.Any <string>()).Returns(entities);
            await _wordRepoMock.AddNewWord(Arg.Any <Anagram>());

            await _wordService.InsertWord(anagram);

            await _wordRepoMock.Received().GetSelectedWordAnagrams(Arg.Any <string>());

            await _wordRepoMock.Received().AddNewWord(Arg.Any <Anagram>());
        }
Ejemplo n.º 2
0
        public async Task InsertWord(Anagram anagram)
        {
            if (anagram == null || string.IsNullOrEmpty(anagram.Category) ||
                string.IsNullOrEmpty(anagram.Word))
            {
                throw new Exception("Canno add Word, because Word is empty");
            }

            var sortedWord       = String.Concat(anagram.Word.OrderBy(x => x));
            var existingAnagrams = await _wordRepository.GetSelectedWordAnagrams(sortedWord);

            ChechForDuplicates(existingAnagrams, anagram);

            await _wordRepository.AddNewWord(anagram);
        }
Ejemplo n.º 3
0
 public void AddNewWord(string word)
 {
     WordsRepository.AddNewWord(word);
 }
        public void AddNewWordFailedWhenFileDoesNotExist()
        {
            Settings.DataFileName = "";

            Assert.ThrowsAsync <Exception>(async() => await _repo.AddNewWord(new Anagram()));
        }