Пример #1
0
        public async Task parser_can_parse_teacher_notebook_with_two_challenges_with_all_components_defined()
        {
            InteractiveDocument document = await ReadDibAsync("forParsing1.dib");

            NotebookLessonParser.Parse(document, out var lesson, out var challenges);

            lesson.Setup.Select(sc => sc.Code).Join("\r\n").Should().ContainAll("lessonSetupCell1", "lessonSetupCell2");

            challenges[0].Name.Should().Be("Challenge1Name");

            challenges[0].Setup.Select(sc => sc.Code).Join("\r\n")
            .Should().ContainAll("challenge1SetupCell1", "challenge1SetupCell2");

            challenges[0].EnvironmentSetup.Select(sc => sc.Code).Join("\r\n")
            .Should().ContainAll("challenge1EnvironmentSetupCell1", "challenge1EnvironmentSetupCell2");

            challenges[0].Contents.Select(sec => sec.Code).Join("\r\n")
            .Should().ContainAll("challenge1QuestionCell1", "challenge1QuestionCell2");

            challenges[1].Name.Should().Be("Challenge2Name");

            challenges[1].Setup.Select(sc => sc.Code).Join("\r\n")
            .Should().ContainAll("challenge2SetupCell1", "challenge2SetupCell2");

            challenges[1].EnvironmentSetup.Select(sc => sc.Code).Join("\r\n")
            .Should().ContainAll("challenge2EnvironmentSetupCell1", "challenge2EnvironmentSetupCell2");

            challenges[1].Contents.Select(sec => sec.Code).Join("\r\n")
            .Should().ContainAll("challenge2QuestionCell1", "challenge2QuestionCell2");
        }
Пример #2
0
        private async Task RunAllCells(FileInfo file, CompositeKernel kernel)
        {
            var notebook = await NotebookLessonParser.ReadFileAsInteractiveDocument(file, kernel);

            foreach (var cell in notebook.Elements.Where(e => e.Language != "markdown"))
            {
                await kernel.SendAsync(new SubmitCode(cell.Contents, cell.Language));
            }
        }
Пример #3
0
        public async Task a_challenge_with_no_question_causes_parser_to_throw_exception()
        {
            InteractiveDocument document = await ReadDibAsync("challengeWithNoQuestion.dib");

            Action parsingDuplicateChallengeName = () => NotebookLessonParser.Parse(document, out var _, out var _);

            parsingDuplicateChallengeName
            .Should().Throw <ArgumentException>()
            .Which.Message.Should().Contain("empty question");
        }
Пример #4
0
        public async Task notebook_with_no_challenge_causes_parser_to_throw_exception()
        {
            InteractiveDocument document = await ReadDibAsync("noChallenge.dib");

            Action parsingDuplicateChallengeName = () => NotebookLessonParser.Parse(document, out var _, out var _);

            parsingDuplicateChallengeName
            .Should().Throw <ArgumentException>()
            .Which.Message.Should().Contain("This lesson has no challenges");
        }
Пример #5
0
        public async Task duplicate_challenge_name_causes_parser_to_throw_exception()
        {
            InteractiveDocument document = await ReadDibAsync("forParsing2DuplicateChallengeName.dib");

            Action parsingDuplicateChallengeName = () => NotebookLessonParser.Parse(document, out var _, out var _);

            parsingDuplicateChallengeName
            .Should().Throw <ArgumentException>()
            .Which.Message.Should().Contain("conflicts");
        }
Пример #6
0
 private async Task <InteractiveDocument> ReadDibAsync(string notebookName)
 {
     return(await NotebookLessonParser.ReadFileAsInteractiveDocument(new FileInfo(GetPatchedNotebookPath(notebookName))));
 }