Beispiel #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);
        }
Beispiel #2
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);
        }