/*public Task AddNewWordPairToDictionaryAsync( * string enword, * string ruword, * string transcription, * TranslationSource sourse) * { * var word = new MongoDAL.Dictionary.DictionaryWord * { * Id = ObjectId.GenerateNewId(), * Language = Language.En, * Source = sourse, * Transcription = transcription, * Word = enword, * Translations = new[] * { * new MongoDAL.Dictionary.DictionaryTranslation * { * Word = ruword, * Language = Language.Ru, * Id = ObjectId.GenerateNewId() * } * } * }; * return _dicRepository.Add(word); * }*/ /* * public Task AddNewWordPairToDictionaryWithPhrasesAsync(string enword, string ruword, * string transcription, TranslationSource source, List<Phrase> examples) * { * var word = new MongoDAL.Dictionary.DictionaryWord * { * Id = ObjectId.GenerateNewId(), * Language = Language.En, * Source = source, * Transcription = transcription, * Word = enword, * Translations = new[] * { * new MongoDAL.Dictionary.DictionaryTranslation * { * Word = ruword, * Language = Language.Ru, * Id = ObjectId.GenerateNewId(), * Examples = examples.Select(p=>new ReferenceToExample * { * OriginExample = p.EnPhrase, * TranslationExample = p.PhraseRuTranslate * }).ToArray() * } * } * }; * return _dicRepository.Add(word); * } */ public async Task <string[]> GetAllTranslationWords(string enword) { var results = await _dicRepository.GetOrDefault(enword); if (results == null) { return(new string[0]); } return(results.Translations.Select(t => t.Word).ToArray()); }
public void AddWord_WordExistsInCollection() { var word = CreateWord("table", "cтол"); _repo.Add(word).Wait(); var read = _repo.GetOrDefault("table").Result; Assert.AreEqual(read.Transcription, word.Transcription); Assert.AreEqual(read.Word, word.Word); Assert.AreEqual(read.Translations.Length, word.Translations.Length); Assert.AreEqual(read.Translations[0].Word, word.Translations[0].Word); Assert.AreEqual(read.Translations[0].Examples.Length, word.Translations[0].Examples.Length); }