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>()); }
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); }
public void AddNewWord(string word) { WordsRepository.AddNewWord(word); }
public void AddNewWordFailedWhenFileDoesNotExist() { Settings.DataFileName = ""; Assert.ThrowsAsync <Exception>(async() => await _repo.AddNewWord(new Anagram())); }