Пример #1
0
        public void ParseSingleSlide()
        {
            var dict = My_ParsingTask.ParseSlideRecords(new[] { slidesHeaderLine, "42;exercise;title" });

            Assert.That(dict, Has.Count.EqualTo(1));
            Assert.That(dict[42], Is.EqualTo(new SlideRecord(42, SlideType.Exercise, "title")));
        }
Пример #2
0
        public void ParseVisits()
        {
            var visits = My_ParsingTask.ParseVisitRecords(
                new[]
            {
                visitsHeaderLine,
                "1;2;2000-01-30;12:00:00",
                "2;2;2000-01-31;12:01:00",
                "1;3;2000-01-29;01:00:00",
                "3;4;2000-02-01;09:10:11"
            },
                new Dictionary <int, SlideRecord>
            {
                { 2, new SlideRecord(2, SlideType.Quiz, "quiz slide") },
                { 3, new SlideRecord(3, SlideType.Exercise, "exercise slide") },
                { 4, new SlideRecord(4, SlideType.Theory, "theory slide") },
                { 5, new SlideRecord(5, SlideType.Theory, "theory slide") }
            });

            Assert.That(visits, Is.EqualTo(new[]
            {
                new VisitRecord(1, 2, new DateTime(2000, 01, 30, 12, 0, 0), SlideType.Quiz),
                new VisitRecord(2, 2, new DateTime(2000, 01, 31, 12, 1, 0), SlideType.Quiz),
                new VisitRecord(1, 3, new DateTime(2000, 01, 29, 01, 0, 0), SlideType.Exercise),
                new VisitRecord(3, 4, new DateTime(2000, 02, 01, 09, 10, 11), SlideType.Theory)
            }));
        }
Пример #3
0
        public void ParseVisits_Fails_OnIncorrectTime()
        {
            var lines     = new[] { visitsHeaderLine, "1;2;2000-01-30;27:99:00" };
            var exception = Assert.Throws <FormatException>(() =>
                                                            My_ParsingTask.ParseVisitRecords(lines, new Dictionary <int, SlideRecord>()).ToList()
                                                            );

            Assert.That(exception.Message, Is.EqualTo("Wrong line [1;2;2000-01-30;27:99:00]"));
        }
Пример #4
0
        public void ParseSeveralSlides()
        {
            var dict =
                My_ParsingTask.ParseSlideRecords(new[] { slidesHeaderLine, "42;exercise;title", "1;quiz;title2" });

            Assert.That(dict, Has.Count.EqualTo(2));
            Assert.That(dict[42], Is.EqualTo(new SlideRecord(42, SlideType.Exercise, "title")));
            Assert.That(dict[1], Is.EqualTo(new SlideRecord(1, SlideType.Quiz, "title2")));
        }
Пример #5
0
        private static void Main()
        {
            var encoding     = Encoding.GetEncoding(1251);
            var slideRecords = My_ParsingTask.ParseSlideRecords(File.ReadAllLines("slides.txt", encoding));
            var visitRecords = My_ParsingTask.ParseVisitRecords(File.ReadAllLines("visits.txt", encoding), slideRecords).ToList();

            foreach (var slideType in new[] { SlideType.Theory, SlideType.Exercise, SlideType.Quiz })
            {
                var time = My_StatisticsTask.GetMedianTimePerSlide(visitRecords, slideType);
                Console.WriteLine("Median time per slide '{0}': {1} mins", slideType, time);
            }
        }
Пример #6
0
        public void SkipIncorrectSlides()
        {
            var dict = My_ParsingTask.ParseSlideRecords(new[] { slidesHeaderLine, "asd;asd;asd" });

            Assert.That(dict, Is.Empty);
        }
Пример #7
0
        public void ParseEmptyVisits()
        {
            var visits = My_ParsingTask.ParseVisitRecords(new[] { visitsHeaderLine }, new Dictionary <int, SlideRecord>());

            Assert.That(visits, Is.Empty);
        }
Пример #8
0
        public void ParseEmptySlides()
        {
            var dict = My_ParsingTask.ParseSlideRecords(new[] { slidesHeaderLine });

            Assert.That(dict, Is.Empty);
        }