public void WhenUserAddsNewWordToDictionary() { var word = "hello"; var newDefinition = "A friendly greeting"; _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); _wordService.AddNewWordToDictionary(Filename, word, newDefinition); _wordService.UpdateDictionaryFile(); var json = TestFileHelper.Read(Filename); var dictionary = JsonConvert.DeserializeObject <Dictionary>(json); dictionary.Words.Should().ContainEquivalentOf(new WordData { Word = word, TemporaryDefinition = null, PermanentDefinition = newDefinition, Status = WordStatus.Permanent }); }
public void WhenNoDefinitionIsEnteredTheWordShouldStillBeWritten() { var newWord = "new"; var newDefinition = ""; _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); _wordService.AddNewWordToDictionary(Filename, newWord, newDefinition); _wordService.UpdateDictionaryFile(); var response = TestFileHelper.Read(Filename); var dictionary = JsonConvert.DeserializeObject <Dictionary>(response); dictionary.Words.Should().ContainEquivalentOf(new WordData { Word = newWord, PermanentDefinition = newDefinition, TemporaryDefinition = null, Status = WordStatus.Permanent }); }
public void WhenADefinitionIsSetThenItShouldBeWrittenToTheDictionary() { var newWord = "new"; var newDefinition = "Something that has only just come into existence"; _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); _wordService.AddNewWordToDictionary(Filename, newWord, newDefinition); _wordService.UpdateDictionaryFile(); var response = TestFileHelper.Read(Filename); var dictionary = JsonConvert.DeserializeObject <Dictionary>(response); dictionary.Words.Should().ContainEquivalentOf(new WordData { Word = newWord, PermanentDefinition = newDefinition, TemporaryDefinition = null, Status = WordStatus.Permanent }); }