コード例 #1
0
        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));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: NatShep/Cho_Ti_Skazal
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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"));
        }
コード例 #8
0
        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());
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: tmteam/Chotiskazal
        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();
        }
コード例 #11
0
        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"));
        }
コード例 #12
0
        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());
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: UnitTest1.cs プロジェクト: tmteam/Chotiskazal
        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);
        }
コード例 #15
0
    // 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!";
        }
    }
コード例 #16
0
 public void Migrate(SQLiteConnection connection, WordsRepository repository)
 {
     connection.Execute(Query);
 }
コード例 #17
0
ファイル: UnitTest1.cs プロジェクト: tmteam/Chotiskazal
        public void ApplyMigrations()
        {
            var repo = new WordsRepository("test");

            repo.ApplyMigrations();
        }
コード例 #18
0
ファイル: UnitTest1.cs プロジェクト: tmteam/Chotiskazal
        public void Setup()
        {
            var repo = new WordsRepository("test");

            File.Delete(repo.DbFile);
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: tmteam/Chotiskazal
        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("===========================================");
            }
        }
コード例 #20
0
ファイル: NewWordsService.cs プロジェクト: tmteam/Chotiskazal
 public NewWordsService(RuengDictionary dictionary, WordsRepository repository)
 {
     _dictionary = dictionary;
     _repository = repository;
 }
コード例 #21
0
 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)));
 }
コード例 #22
0
ファイル: UnitTest1.cs プロジェクト: tmteam/Chotiskazal
        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);
        }
コード例 #23
0
 public TextProcessingDataContext(IDbContextFactory <UniqueWordsDbContext> dbContextFactory)
     : base(dbContextFactory)
 {
     WordsRepository      = new WordsRepository(DbContext);
     WatchWordsRepository = new WatchWordsRepository(DbContext);
 }
コード例 #24
0
 public void Should_Return_Not_Empy_Hashset()
 {
     wordsRepository = new WordsRepository(config);
     Assert.IsTrue(wordsRepository.GetWords().GetType() == typeof(HashSet <WordModel>) && wordsRepository.GetWords().Count > 0);
 }
コード例 #25
0
 public DutchWordsService(WordsRepository _fileRepository)
 {
     fileRepository = _fileRepository;
 }
コード例 #26
0
 public VocabularyModel(WordsRepository wordsRepository)
 {
     _wordsRepository = wordsRepository;
 }