Ejemplo n.º 1
0
        public void GetAllEntries_ProperConditions_ReturnsAllEntries(string filePath, int numOfLines)
        {
            var fileValidator    = new FileValidator(new ValidationData());
            var setService       = new SetService(fileValidator);
            var fileSource       = new EmbeddedSource(filePath, Assembly.GetExecutingAssembly());
            var wordsSetOperator = new WordsSetOperator(setService, fileSource);

            if (!wordsSetOperator.LoadSet())
            {
                throw new Exception("Set is null.");
            }

            int index = 0;

            foreach (Entry?entry in wordsSetOperator.GetEntries(false, true))
            {
                if (entry == null)
                {
                    break;
                }
                index++;
            }

            Assert.Equal(numOfLines, index);
        }
Ejemplo n.º 2
0
        private LearningModeOperator GetLearningModeOperator()
        {
            var fileValidator = new FileValidator(new ValidationData());
            var setService    = new SetService(fileValidator);
            var fileSources   = new List <ISource>();

            for (int i = 0; i < FilePaths.Count; i++)
            {
                string absolutePath = AppSettings.Words != null
                    ? AppSettings.Words.SetsDirectoryPath
                    : AppDomain.CurrentDomain.BaseDirectory;
                if (FilePaths[i].StartsWith('.'))
                {
                    absolutePath = AppDomain.CurrentDomain.BaseDirectory;
                }
                string filePath = Path.Combine(absolutePath, FilePaths[i].TrimStart('.', '\\', '/'));
                SetFileExists(filePath);
                fileSources.Add(new FileSource(filePath));
            }
            var wordsSetOperator     = new WordsSetOperator(setService, fileSources);
            var learningModeOperator = new LearningModeOperator(wordsSetOperator, AppSettings.Learning, Mode);

            return(learningModeOperator);
        }
Ejemplo n.º 3
0
        public void RandomizeEntries_ProperConditions_ReturnsEntriesInRandomOrder(string filePath)
        {
            var fileValidator    = new FileValidator(new ValidationData());
            var setService       = new SetService(fileValidator);
            var fileSource       = new EmbeddedSource(filePath, Assembly.GetExecutingAssembly());
            var wordsSetOperator = new WordsSetOperator(setService, fileSource);

            if (!wordsSetOperator.LoadSet())
            {
                throw new Exception("Set is null.");
            }

            string str1 = "";

            foreach (Entry?entry1 in wordsSetOperator.GetEntries(false, true))
            {
                if (entry1 == null)
                {
                    break;
                }
                str1 += string.Join(',', entry1.Words) + ',' + string.Join(',', entry1.Translations);
            }

            string str2 = "";

            foreach (Entry?entry2 in wordsSetOperator.GetEntries(false, true))
            {
                if (entry2 == null)
                {
                    break;
                }
                str1 += string.Join(',', entry2.Words) + ',' + string.Join(',', entry2.Translations);
            }

            Assert.NotEqual(str1, str2);
        }