示例#1
0
        public void ReportWarning_If_WrongAnswers_Have_Errors()
        {
            var validatorOut = TestsHelper.ValidateBlock(exerciseBlock);

            validatorOut
            .Should()
            .Contain(
                $"Code verdict of file with wrong answer ({exerciseBlock.UserCodeFileNameWithoutExt}.WrongAnswer.Type.cs) is not OK.")
            .And
            .Contain("Verdict: CompilationError");
            validatorOut
            .Should().Contain(
                $"Code of file with wrong answer ({exerciseBlock.UserCodeFileNameWithoutExt}.WrongAnswer.21.plus.21.cs) is solution!");
            validatorOut
            .Should().NotContain($"{exerciseBlock.UserCodeFileNameWithoutExt}.WrongAnswer.27.cs");
        }
        public void ReportError_If_Solution_For_ProjectExerciseBlock_Is_Not_Solution()
        {
            exerciseBlock.NUnitTestClasses = new[] { $"test.{nameof(OneFailingTest)}" };
            exerciseBlock.ReplaceStartupObjectForNUnitExercises();

            var validatorOutput = TestsHelper.ValidateBlock(exerciseBlock);

            validatorOutput
            .Should()
            .Contain(
                $"Correct solution file {exerciseBlock.CorrectSolutionFileName} is not solution. RunResult = Id: test.csproj, Verdict: Ok")
            .And
            .Contain("Как минимум один из тестов не пройден")
            .And
            .Contain("I_am_a_failure");
        }
        public void OneTimeSetUp()
        {
            TestsHelper.RecreateDirectory(tempSlideFolderPath);
            FileSystem.CopyDirectory(TestsHelper.ProjSlideFolderPath, tempSlideFolderPath);

            string studentZipFilepath = Path.Combine(tempSlideFolderPath, "ProjDir.exercise.zip");

            if (File.Exists(studentZipFilepath))
            {
                File.Delete(studentZipFilepath);
            }

            var ctx = new BuildUpContext(new Unit(null, exBlock.SlideFolderPath), CourseSettings.DefaultSettings, null, "Test", string.Empty);

            exBlock.BuildUp(ctx, ImmutableHashSet <string> .Empty).ToList();
        }
示例#4
0
        public void Not_Report_Indentation_Warning_On_Ethalon_Solution_Of_SingleFileExercise()
        {
            var exerciseXmlFile = TestsHelper.ProjSlideFolder.GetFile("S055 - Упражнение на параметры по умолчанию.lesson.xml");

            var courseSettings = new CourseSettings(CourseSettings.DefaultSettings)
            {
                Preludes = new[] { new PreludeFile(Language.CSharp, TestsHelper.ProjSlideFolder.GetFile("Prelude.cs").FullName) }
            };

            var unit = new Unit(UnitSettings.CreateByTitle("Unit title", courseSettings), TestsHelper.ProjSlideFolder);
            var slideLoadingContext = new SlideLoadingContext("Test", unit, courseSettings, TestsHelper.ProjSlideFolder, exerciseXmlFile, 1);
            var exerciseSlide       = (ExerciseSlide) new XmlSlideLoader().Load(slideLoadingContext);

            var validatorOut = TestsHelper.ValidateExerciseSlide(exerciseSlide);

            validatorOut.Should().BeNullOrEmpty();
        }
示例#5
0
        public void OneTimeSetUp()
        {
            TestsHelper.RecreateDirectory(tempSlideFolderPath);
            FileSystem.CopyDirectory(TestsHelper.ProjSlideFolderPath, tempSlideFolderPath);

            string studentZipFilepath = Path.Combine(tempSlideFolderPath, "ProjDir.exercise.zip");

            if (File.Exists(studentZipFilepath))
            {
                File.Delete(studentZipFilepath);
            }

            var ctx = new SlideBuildingContext("Test", new Unit(null, exerciseBlock.SlideFolderPath), CourseSettings.DefaultSettings, exerciseBlock.SlideFolderPath, null);

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            exerciseBlock.BuildUp(ctx, ImmutableHashSet <string> .Empty).ToList();
        }
        public void ReportError_If_StudentZip_HasErrors()
        {
            FileSystem.CopyDirectory(tempSlideFolder.GetSubdirectory("projDir").FullName,
                                     tempSlideFolder.GetSubdirectory("FullProjDir").FullName);
            exerciseBlock.CsProjFilePath = Path.Combine("FullProjDir", TestsHelper.CsProjFilename);
            SaveTempZipFileWithFullProject();

            var validatorOutput = TestsHelper.ValidateBlock(exerciseBlock);

            validatorOutput
            .Should().Contain(
                $"Student zip exercise directory has 'wrong answer' and/or solution files ({TestsHelper.OrderedWrongAnswersAndSolutionNames})");
            validatorOutput
            .Should().Contain($"Student's csproj has user code item ({exerciseBlock.UserCodeFilePath}) of not compile type");
            validatorOutput
            .Should().Contain(
                $"Student's csproj has 'wrong answer' and/or solution items ({TestsHelper.OrderedWrongAnswersAndSolutionNames})");
        }
        public void OneTimeSetUp()
        {
            TestsHelper.RecreateDirectory(tempSlideFolderPath);
            FileSystem.CopyDirectory(TestsHelper.ProjSlideFolderPath, tempSlideFolderPath);

            TestsHelper.RecreateDirectory(checkerExerciseFolderPath);
            TestsHelper.RecreateDirectory(studentExerciseFolderPath);

            Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);

            ex = new CsProjectExerciseBlock
            {
                StartupObject            = "test.Program",
                UserCodeFilePath         = TestsHelper.UserCodeFileName,
                SlideFolderPath          = tempSlideFolder,
                CsProjFilePath           = TestsHelper.CsProjFilePath,
                PathsToExcludeForStudent = new[] { "inner-dir-1\\inner-dir-2\\ExcludeMeForStudent.cs" }
            };

            var unit = new Unit(null, ex.SlideFolderPath);
            var ctx  = new SlideBuildingContext("Test", unit, CourseSettings.DefaultSettings, unit.Directory, null);

            exBlocks = ex.BuildUp(ctx, ImmutableHashSet <string> .Empty).ToList();

            var builder = new ExerciseStudentZipBuilder();

            builder.BuildStudentZip(new ExerciseSlide(exBlocks.ToArray()), studentExerciseZipFilePath);

            Utils.UnpackZip(studentExerciseZipFilePath.ReadAllContent(), studentExerciseFolderPath);

            var zipBytes = ex.GetZipBytesForChecker("i_am_user_code");

            Utils.UnpackZip(zipBytes, checkerExerciseFolderPath);

            studentZipCsproj = new Project(studentCsProjFilePath, null, null, new ProjectCollection());
            checkerZipCsproj = new Project(checkerCsprojFilePath, null, null, new ProjectCollection());
        }
 public void OneTimeSetUp()
 {
     BasicConfigurator.Configure();
     TestsHelper.RecreateDirectory(tempSlideFolderPath);
 }
 public void OneTimeSetUp()
 {
     TestsHelper.RecreateDirectory(tempSlideFolderPath);
 }