public async Task IsValidWord(string word, string group) { var isValid = _wordService.GetWordStatus(_filenameHelper.GetDictionaryFilename(), word); _wordService.AddWordToGuessedWords(_filenameHelper.GetDictionaryFilename(), _filenameHelper.GetGuessedWordsFilename(), word); await Clients.Group(group).SendAsync("WordStatusResponse", isValid, word); }
public AmendDictionaryTests() { var data = new Dictionary { Words = new List <WordData> { new WordData { Word = "pelican", Status = WordStatus.Temporary, PermanentDefinition = null, TemporaryDefinition = null } } }; _filenameHelper = Substitute.For <IFilenameHelper>(); _filenameHelper .GetGuessedWordsFilename() .Returns(GuessedWordsFilename); _filenameHelper.GetDictionaryFilename().Returns(Filename); TestFileHelper.CreateCustomFile(Filename, data); _fileHelper = new FileHelper(); _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); }
public LettersHub(IWordService wordService, IFileHelper fileHelper, IFilenameHelper filenameHelper, IJoinRoomHelper joinRoomHelper, IGameManager gameManager) { _wordService = wordService; _fileHelper = fileHelper; _filenameHelper = filenameHelper; _joinRoomHelper = joinRoomHelper; _gameManager = gameManager; if (!File.Exists(_filenameHelper.GetDictionaryFilename())) { File.Create(_filenameHelper.GetDictionaryFilename()); } if (!File.Exists(_filenameHelper.GetGuessedWordsFilename())) { File.Create(_filenameHelper.GetGuessedWordsFilename()); } }
public UpdateExistingWordInDictionary() { _filenameHelper = Substitute.For <IFilenameHelper>(); _filenameHelper .GetGuessedWordsFilename() .Returns(Filename); _filenameHelper.GetDictionaryFilename().Returns(Filename); TestFileHelper.Create(Filename); _fileHelper = new FileHelper(); _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); }
public AddWordToGuessedWordsTest() { _dictionary = new Dictionary { Words = new List <WordData> { new WordData { Word = _words[0], PermanentDefinition = null, TemporaryDefinition = null, Status = WordStatus.Permanent }, new WordData { Word = _words[1], PermanentDefinition = null, TemporaryDefinition = null, Status = WordStatus.Temporary }, new WordData() { Word = _words[2], PermanentDefinition = null, TemporaryDefinition = null, Status = WordStatus.Suffix }, new WordData() { Word = _words[3], PermanentDefinition = null, TemporaryDefinition = null, Status = WordStatus.DoesNotExist } } }; _filenameHelper = Substitute.For <IFilenameHelper>(); _filenameHelper .GetGuessedWordsFilename() .Returns(GuessedWordsFilename); _filenameHelper.GetDictionaryFilename().Returns(DictionaryFilename); TestFileHelper.CreateCustomFile(GuessedWordsFilename, null); TestFileHelper.CreateCustomFile(DictionaryFilename, _dictionary); _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); }
public AddNewWordToDictionaryTests() { _wordDefinitionHelper = Substitute.For <IWordDefinitionHelper>(); _wordExistenceHelper = Substitute.For <IWordExistenceHelper>(); _wordHelper = Substitute.For <IWordHelper>(); _fileHelper = new FileHelper(); _filenameHelper = Substitute.For <IFilenameHelper>(); _filenameHelper.GetDictionaryFilename().Returns(Filename); _filenameHelper.GetGuessedWordsFilename().Returns(Filename); if (File.Exists(Filename)) { File.Delete(Filename); } TestFileHelper.Create(Filename); }
public AutomaticallySetTemporaryDefinitions() { TestFileHelper.Create(Filename); var json = TestFileHelper.Read(Filename); _webDictionaryRequestHelper = Substitute.For <IWebDictionaryRequestHelper>(); _wordExistenceHelper = Substitute.For <IWordExistenceHelper>(); _wordDefinitionHelper = Substitute.For <IWordDefinitionHelper>(); _fileHelper = new FileHelper(); _filenameHelper = Substitute.For <IFilenameHelper>(); _filenameHelper.GetGuessedWordsFilename().Returns(Filename); _filenameHelper.GetDictionaryFilename().Returns(Filename); _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); _dictionary = _wordService.GetDictionary(); }
public WordService(IWordExistenceHelper wordExistenceHelper, IWordHelper wordHelper, IWordDefinitionHelper wordDefinitionHelper, IFileHelper fileHelper, IFilenameHelper filenameHelper) { _wordExistenceHelper = wordExistenceHelper; _wordHelper = wordHelper; _wordDefinitionHelper = wordDefinitionHelper; _fileHelper = fileHelper; _filenameHelper = filenameHelper; if (_dictionary == null) { Console.WriteLine("Hello"); _dictionary = _fileHelper.ReadDictionary(_filenameHelper.GetDictionaryFilename()); } if (_guessedWords == null) { Console.WriteLine("Guessed words"); var json = _fileHelper.ReadFile(_filenameHelper.GetGuessedWordsFilename()); _guessedWords = JsonConvert.DeserializeObject <GuessedWords>(json) ?? new GuessedWords(); } }
public WordStatusTests() { _filenameHelper = Substitute.For <IFilenameHelper>(); _filenameHelper .GetGuessedWordsFilename() .Returns(Filename); _filenameHelper .GetDictionaryFilename() .Returns(Filename); TestFileHelper.Create(Filename); var json = TestFileHelper.Read(Filename); _wordDefinitionHelper = Substitute.For <IWordDefinitionHelper>(); _wordExistenceHelper = Substitute.For <IWordExistenceHelper>(); _wordHelper = Substitute.For <IWordHelper>(); _fileHelper = new FileHelper(); _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); _dictionary = _wordService.GetDictionary(); }
public AutomaticallyAddNewWordToDictionaryTests() { _wordDefinitionHelper = Substitute.For <IWordDefinitionHelper>(); _wordExistenceHelper = Substitute.For <IWordExistenceHelper>(); _wordHelper = Substitute.For <IWordHelper>(); _filenameHelper = Substitute.For <IFilenameHelper>(); _filenameHelper.GetDictionaryFilename().Returns(Filename); _filenameHelper.GetGuessedWordsFilename().Returns(Filename); _fileHelper = new FileHelper(); if (File.Exists(Filename)) { File.Delete(Filename); } TestFileHelper.Create(Filename); _wordService = new WordService(_wordExistenceHelper, _wordHelper, _wordDefinitionHelper, _fileHelper, _filenameHelper); var json = TestFileHelper.Read(Filename); _dictionary = _wordService.GetDictionary(); }
public void UpdateGuessedWordsFile() { _fileHelper.WriteFile(_filenameHelper.GetGuessedWordsFilename(), _guessedWords); }