public void GetOrNullPair_ReturnsPhrase() { var repo = new WordsRepository("test"); repo.ApplyMigrations(); var word = repo.GetOrNullWithPhrases("word"); Assert.IsNotNull(word.Phrases); Assert.AreEqual(1, word.Phrases.Count); Assert.AreEqual("what is word", word.Phrases[0].Origin); }
static void Main() { TaskScheduler.UnobservedTaskException += (sender, args) => Console.WriteLine($"Unobserved ex {args.Exception}"); var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false); IConfigurationRoot configuration = builder.Build(); var yadicapiKey = configuration.GetSection("yadicapi").GetSection("key").Value; var yadicapiTimeout = TimeSpan.FromSeconds(5); var dbFileName = configuration.GetSection("wordDb").Value; var yatransapiKey = configuration.GetSection("yatransapi").GetSection("key").Value; var yatransapiTimeout = TimeSpan.FromSeconds(5); _yapiDicClient = new YandexDictionaryApiClient(yadicapiKey, yadicapiTimeout); _yapiTransClient = new YandexTranslateApiClient(yatransapiKey, yatransapiTimeout); var repo = new WordsRepository(dbFileName); repo.ApplyMigrations(); Console.WriteLine("Dic started"); _wordsService = new NewWordsService(new RuengDictionary(), repo); _botClient = new TelegramBotClient(ApiToken); var me = _botClient.GetMeAsync().Result; Console.WriteLine( $"Hello, World! I am user {me.Id} and my name is {me.FirstName}." ); _botClient.OnUpdate += BotClientOnOnUpdate; _botClient.OnMessage += Bot_OnMessage; _botClient.StartReceiving(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); _botClient.StopReceiving(); }
public void GetOrNullPair_ReturnsPhrase() { var repo = new WordsRepository("test"); repo.ApplyMigrations(); repo.CreateNew("word", "translation", "trans", new[] { new Phrase() { Created = DateTime.Now, Origin = "what is word", OriginWord = "word", Translation = "trans is trans", TranslationWord = "trans" } }); var word = repo.GetOrNullWithPhrases("word"); Assert.IsNotNull(word.Phrases); Assert.AreEqual(1, word.Phrases.Count); Assert.AreEqual("what is word", word.Phrases[0].Origin); }
public void GetWorst10_ReturnsPhrase() { var repo = new WordsRepository("test"); repo.ApplyMigrations(); repo.CreateNew("word", "translation", "trans", new[] { new Phrase() { Created = DateTime.Now, Origin = "what is word", OriginWord = "word", Translation = "trans is trans", TranslationWord = "trans" }, new Phrase() { Created = DateTime.Now, Origin = "what is word 2", OriginWord = "word", Translation = "trans is trans 2", TranslationWord = "trans" }, }); repo.CreateNew("word2", "translation2", "trans", new[] { new Phrase() { Created = DateTime.Now, Origin = "what is word", OriginWord = "word2", Translation = "trans is trans", TranslationWord = "trans2" }, new Phrase() { Created = DateTime.Now, Origin = "what is word 2", OriginWord = "word2", Translation = "trans is trans 2", TranslationWord = "trans2" }, }); repo.CreateNew("word3", "translation3", "trans", new[] { new Phrase() { Created = DateTime.Now, Origin = "what is word", OriginWord = "word3", Translation = "trans is trans", TranslationWord = "trans3" }, new Phrase() { Created = DateTime.Now, Origin = "what is word 3", OriginWord = "word3", Translation = "trans is trans 3", TranslationWord = "trans3" }, }); var words = repo.GetWorst(2); Assert.IsNotNull(words); Assert.AreEqual(2, words.Length); }
public void ApplyMigrations() { var repo = new WordsRepository("test"); repo.ApplyMigrations(); }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false); IConfigurationRoot configuration = builder.Build(); var yadicapiKey = configuration.GetSection("yadicapi").GetSection("key").Value; var yadicapiTimeout = TimeSpan.FromSeconds(5); var dbFileName = configuration.GetSection("wordDb").Value; var yatransapiKey = configuration.GetSection("yatransapi").GetSection("key").Value; var yatransapiTimeout = TimeSpan.FromSeconds(5); var yapiDicClient = new YandexDictionaryApiClient(yadicapiKey, yadicapiTimeout); var yapiTransClient = new YandexTranslateApiClient(yatransapiKey, yatransapiTimeout); var modes = new IConsoleMode[] { new ExamMode(), new WordAdditionMode(yapiTransClient, yapiDicClient), new GraphsStatsMode(), // new RandomizeMode(), // new AddPhraseToWordsMode(yapiDicClient), }; var repo = new WordsRepository(dbFileName); repo.ApplyMigrations(); Console.WriteLine("Dic started"); //var metrics = repo.GetAllQuestionMetrics(); //string path = "T:\\Dictionary\\eng_rus_full.json"; //Console.WriteLine("Loading dictionary"); //var dictionary = Dic.Logic.Dictionaries.Tools.ReadFromFile(path); var service = new NewWordsService(new RuengDictionary(), repo); Console.Clear(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(@" ____ _ _ ____ ___ _ ____ _ _ ____ ___ ____ _ | |__| | | | | [__ |_/ |__| / |__| | |___ | | |__| | | ___] | \_ | | /__ | | |___ "); Console.ResetColor(); while (true) { Console.WriteLine(); Console.WriteLine("ESC: Quit"); for (int i = 0; i < modes.Length; i++) { Console.WriteLine($"{i+1}: {modes[i].Name}"); } Console.WriteLine(); Console.Write("Choose mode:"); var val = Console.ReadKey(); Console.WriteLine(); if (val.Key == ConsoleKey.Escape) { return; } var choice = ((int)val.Key - (int)ConsoleKey.D1); if (choice > -1 && choice < modes.Length) { var selected = modes[choice]; Console.Clear(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("====== " + selected.Name + " ======"); Console.ResetColor(); modes[choice].Enter(service); } Console.WriteLine(); Console.WriteLine("==========================================="); } }