public async Task <IActionResult> Manual(int categoryId) { Tuple <int, int> ids = Helper.GetLanguagesId(); int nativeLang = ids.Item1; int learningLang = ids.Item2; WordsRepository wordsRepository = new WordsRepository(); List <DTO> words = wordsRepository.GetDTO(nativeLang, learningLang, categoryId); return(View(words)); }
public void WhenGetIsCalledTheTopNumberOfEntitiesRequestedAreReturned() { var sut = new WordsRepository(); const int take = 2; var expectedOrder = _expectedWordMetrics.OrderByDescending(w => w.Count).Take(take); var words = sut.GetTop <CountVonCountTestDbContext>(2); CollectionAssert.AreEqual(expectedOrder, words, new WordMetricComparer()); }
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); }
public WordDTO Get(int id) { var identity = HttpContext.User.Identity as ClaimsIdentity; var UserId = identity.FindFirst(ClaimTypes.Name).Value; if (identity == null) { Response.StatusCode = 404; } int userId = Int32.Parse(UserId); return(WordsRepository.GetWordId(userId, id)); }
public HomeController(IHttpContextAccessor httpContextAccessor) { _categoriesRepository = new CategoriesRepository(); _wordsRepository = new WordsRepository(); _testsRepository = new TestsRepository(); string userLogin = httpContextAccessor?.HttpContext?.User?.FindFirst("userLogin")?.Value; if (userLogin != null) { _currentUser = new UsersRepository().GetByEmailOrName(userLogin); } }
public List <WordDTO> Get() { var identity = HttpContext.User.Identity as ClaimsIdentity; var userId = identity.FindFirst(ClaimTypes.Name).Value; if (identity == null) { Response.StatusCode = 404; } int ID = Int32.Parse(userId); return(WordsRepository.GetWordsList(ID)); }
public void ContainsWordShouldReturnFalseIfNotContained() { var words = new List <string>() { "house", "car" }; wordsReaderMock .Setup(reader => reader.GetAllWords()) .Returns(words); repo = new WordsRepository(wordsReaderMock.Object); Assert.False(repo.ContainsWord("motorcycle")); }
public void GetAllWordsShouldReturnAllTheWords() { var words = new List <string>() { "house", "car" }; wordsReaderMock .Setup(reader => reader.GetAllWords()) .Returns(words); repo = new WordsRepository(wordsReaderMock.Object); Assert.Equal(words, repo.GetAllWords()); }
public WordDTO Get() { var identity = HttpContext.User.Identity as ClaimsIdentity; var id = identity.FindFirst(ClaimTypes.Name).Value; //dekoduje id usera z tokena if (identity == null) { Response.StatusCode = 404; return(null); } int ID = int.Parse(id); var response = WordsRepository.GetRandomWord(ID); //id usera return(response); }
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 GetWordsStartingLikeShouldReturnOnlyTheRightWords() { var words = new List <string>() { "ho", "house", "car" }; wordsReaderMock .Setup(reader => reader.GetAllWords()) .Returns(words); repo = new WordsRepository(wordsReaderMock.Object); Assert.Equal(new List <string>() { "ho", "house" }, repo.GetWordsStartingLike("ho")); }
static void Main() { using (Mutex mutex = new Mutex(false, "Global\\" + AppUuid)) { if (!mutex.WaitOne(0, false)) { MessageBox.Show(@"Vienu metu galima paleisti tik vieną SilverLinguo aplikaciją!"); return; } var wordsRepository = new WordsRepository(); wordsRepository.InitializeDatabaseIfNotExist(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new StartupForm()); } }
public void AddNewWordAtWordsRepository_NewWordAtWordsRepository() { Word word = new Word(Guid.NewGuid(), "tea", "чай", 0); List <Word> inMemoryWords = new List <Word>(); User user = new User("Artem", Guid.NewGuid(), inMemoryWords); UserRepository userRepository = new UserRepository(@"/Users/odmen/Projects/EnglishTrainer/EnglishTrainer/bin/user.json"); WordsRepository wordsRepository = new WordsRepository(@"/Users/odmen/Projects/EnglishTrainer/EnglishTrainer/bin/testWords.json"); UserService userService = new UserService(wordsRepository, userRepository); Session session = new Session(user, wordsRepository, userService); UserFacade userFacade = new UserFacade(userService, session); userFacade.AddWordAtUserWordsRepository(user, word); List <Word> expected = new List <Word>() { word }; List <Word> arr = new List <Word>(); arr = user._inMemoryWords.Where(item => item.Id_Word == word.Id_Word).Select(item => item).ToList(); Equals(arr, expected); }
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); }
// Use this for initialization when manager is enabled with "setActive" void OnEnable() { Debug.Log("OnEnabled BattleManager"); // Prevent to init on very first start of the game if (GameManager.instance != null && GameManager.instance.isBattle) { WordsRepository = XmlManager.Deserialize <WordsRepository>(); WordLevel wordLevel = EmotionMenager.GetInstance().WordLevelDifficulty(); ActiveWord = new WordToType(WordsRepository.GetRandomWord(wordLevel), WordSpawner.SpawnWord()); // get random enemy from prefabs Debug.Log("Init enemy:"); EnemyType enemyType = getEnemyType(); Debug.Log(enemyType); if (enemyType.Equals(EnemyType.Wolf)) { Debug.Log("Loading Wolf."); enemy = Instantiate(Resources.Load("Prefabs/WolfBattle", typeof(GameObject)), enemyPosition.position, Quaternion.identity) as GameObject; } else if (enemyType.Equals(EnemyType.Zombie)) { Debug.Log("Loading Zombie."); enemy = Instantiate(Resources.Load("Prefabs/Zombie1Battle", typeof(GameObject)), enemyPosition.position, Quaternion.identity) as GameObject; } Debug.Log(enemy); // enemy.transform.parent = enemyPosition; //set up player&enemy health text Debug.Log("Player health: "); Debug.Log(playerInBattle.GetComponent <PlayerInBattle>().health); Debug.Log("Enemy health: "); Debug.Log(enemy.GetComponent <EnemyInBattle>().health); maxEnemyHealth = enemy.GetComponent <EnemyInBattle>().health; playerHealth.text = playerInBattle.GetComponent <PlayerInBattle>().health + "/" + Player.maxHealth; enemyHealth.text = enemy.GetComponent <EnemyInBattle>().health + "/" + enemy.GetComponent <EnemyInBattle>().health; headline.text = "Fight!"; } }
public void Migrate(SQLiteConnection connection, WordsRepository repository) { connection.Execute(Query); }
public void ApplyMigrations() { var repo = new WordsRepository("test"); repo.ApplyMigrations(); }
public void Setup() { var repo = new WordsRepository("test"); File.Delete(repo.DbFile); }
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("==========================================="); } }
public NewWordsService(RuengDictionary dictionary, WordsRepository repository) { _dictionary = dictionary; _repository = repository; }
public void Shoud_Correctly_Parse_All_Unique_Words_From_Input_File(object[] inputWords) { wordsRepository = new WordsRepository(config); Assert.IsTrue(inputWords.All(inputWord => wordsRepository.GetWords().Any(word => word.word == (string)inputWord))); }
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 TextProcessingDataContext(IDbContextFactory <UniqueWordsDbContext> dbContextFactory) : base(dbContextFactory) { WordsRepository = new WordsRepository(DbContext); WatchWordsRepository = new WatchWordsRepository(DbContext); }
public void Should_Return_Not_Empy_Hashset() { wordsRepository = new WordsRepository(config); Assert.IsTrue(wordsRepository.GetWords().GetType() == typeof(HashSet <WordModel>) && wordsRepository.GetWords().Count > 0); }
public DutchWordsService(WordsRepository _fileRepository) { fileRepository = _fileRepository; }
public VocabularyModel(WordsRepository wordsRepository) { _wordsRepository = wordsRepository; }