Пример #1
0
        public void Init()
        {
            Root = Path.Combine(Directory.GetCurrentDirectory(), nameof(SnapshotReportGeneratorTests));
            AbstractSyntaxTreeGenerator = new MockAbstractSyntaxTreeGenerator {
                Throw = false
            };
            Reports   = new MockRepository <SnapshotReport, int>();
            Generator = new SnapshotReportGenerator(
                AbstractSyntaxTreeGenerator,
                new MockAbstractSyntaxTreeClassExtractor(), Reports,
                new MockSnapshotMethodGenerator(),
                new MockUnitTestGenerator()
                );
            Data = new SubmissionData(new StudentSubmissionDto()
            {
                ClassName      = "ClassName",
                StudentName    = "StudentName",
                SnapshotFolder = MockSnapshots.GetCalculatorSnapshots(),
            }, Root);

            Assignment = new Assignment()
            {
                Filename = MockSnapshots.GetCalculatorFile(),
                Solution = new AssignmentSolution()
                {
                    Name = MockSnapshots.GetCalculatorClassName(),
                },
            };
        }
 public void HasSourceFile_ShouldThrowExceptionForBadSnapshotName()
 {
     using (var data = new SubmissionData(Submission, Root))
     {
         data.HasSourceFile("Random", MockSnapshots.GetCalculatorFile());
     }
 }
        public void Create_ShouldReturnValidNodeForCalculatorSnapshot()
        {
            var node = Generator.CreateFromFile(Data,
                                                Data.SnapshotSourceFileFullPath(MockSnapshots.GetFirstCalculatorSnapshotName(),
                                                                                MockSnapshots.GetCalculatorFile()));

            Assert.AreEqual(ValidNode, node.Value);
        }
 public void HasSourceFile_ShouldPassForEachSnapshot()
 {
     using (var data = new SubmissionData(Submission, Root))
     {
         foreach (var folder in data.SnapshotFolderNames())
         {
             Assert.IsTrue(data.HasSourceFile(folder,
                                              MockSnapshots.GetCalculatorFile()));
         }
     }
 }
Пример #5
0
        public async Task AddSubmissionToStudentSubmission_UnzipFilesShouldGetFile()
        {
            var snapshotSubmission = await GeneratorObj.AddSubmissionToStudentSubmission(
                MockSnapshots.GetThirdCalculatorSnapshotName());

            var files    = (await SnapshotSubmission.Get(snapshotSubmission.Id)).Files;
            var snapshot = "Snapshot";

            EngineFileUtilities.ExtractZip(Data.Root, snapshot, files);

            var path = Path.Combine(Data.Root, snapshot, MockSnapshots.GetCalculatorFile());

            Assert.IsTrue(File.Exists(path));
        }
Пример #6
0
        public void Init()
        {
            Root    = Path.Combine(Directory.GetCurrentDirectory(), nameof(AssignmentGeneratorTests));
            Handler = new DirectoryHandler(Root);
            PreAssignmentRepository = new MockRepository <PreAssignment, int>();

            Assignment = new PreAssignment()
            {
                PreAssignmentReport = new PreAssignmentPendingReport(),
                Filename            = MockSnapshots.GetCalculatorFile(),
                Solution            = new AssignmentSolution()
                {
                    Id    = 1,
                    Name  = MockSnapshots.GetCalculatorClassName(),
                    Files = MockSnapshots.GetCalculatorSolutionFiles(),
                    MethodDeclarations = MockSnapshots.GetCalculatorMethodDeclaration().ToList(),
                },
                AssignmentSolutionId = 1,
                TestProject          = new TestProject()
                {
                    Files           = MockSnapshots.GetCalculatorTestProjectFiles(),
                    TestFolder      = MockSnapshots.GetCalculatorTestProjectFolder(),
                    TestDllFile     = MockSnapshots.GetCalculatorTestProjectDll(),
                    TestProjectFile = MockSnapshots.GetCalculatorTestProjectFile()
                }
            };

            PreAssignmentRepository.Add(Assignment);
            AbstractSyntaxTreeGenerator       = new MockAbstractSyntaxTreeGenerator();
            AbstractSyntaxTreeClassExtractor  = new MockAbstractSyntaxTreeClassExtractor();
            AbstractSyntaxTreeMethodExtractor = new MockAbstractSyntaxTreeMethodExtractor();
            UnitTestGenerator = new MockUnitTestGenerator();

            Generator = new AssignmentGenerator(PreAssignmentRepository,
                                                AbstractSyntaxTreeGenerator,
                                                AbstractSyntaxTreeClassExtractor,
                                                AbstractSyntaxTreeMethodExtractor,
                                                UnitTestGenerator
                                                );
        }
Пример #7
0
        public void Init()
        {
            Root = Path.Combine(Directory.GetCurrentDirectory(), nameof(SnapshotGeneratorTests));

            Submission = new StudentSubmissionDto()
            {
                SnapshotFolder = MockSnapshots.GetCalculatorSnapshots(),
                StudentName    = StudentName,
                ClassName      = "Class",
            };
            Assignment = new Assignment()
            {
                Id       = AssignmentId,
                Filename = MockSnapshots.GetCalculatorFile(),
                Solution = new AssignmentSolution()
                {
                    Files = MockSnapshots.GetCalculatorSolutionFiles(),
                    Name  = MockSnapshots.GetCalculatorClassName(),
                }
            };

            Student =
                new Student()
            {
                Id          = StudentId,
                Name        = StudentName,
                Submissions = new List <SnapshotSubmission>()
                {
                    new SnapshotSubmission()
                    {
                        Id = FirstCalculatorSubmissionId,
                        CreatedDateTime = MockSnapshots.GetFirstCalculatorSnapshotTime(),
                    }
                },
                Snapshots = new List <Snapshot>()
                {
                    new Snapshot()
                    {
                        Id = FirstCalculatorSubmissionId,
                        SnapshotSubmission = new SnapshotSubmission()
                        {
                            Id = FirstCalculatorSubmissionId,
                            CreatedDateTime = MockSnapshots.GetFirstCalculatorSnapshotTime(),
                            Files           = MockSnapshots.GetFirstCalculatorSnapshotFile(),
                        },
                        AssignmentId = AssignmentId
                    },
                    new Snapshot()
                    {
                        Id = LastSnapshotId,
                        SnapshotSubmission = new SnapshotSubmission()
                        {
                            Id = 2,
                            CreatedDateTime = MockSnapshots.GetSecondCalculatorSnapshotTime(),
                            Files           = MockSnapshots.GetSecondCalculatorSnapshotFile(),
                        },
                        AssignmentId = AssignmentId
                    }
                }
            };
            Students = new MockRepository <Student, string>();
            Students.Add(Student);
            Snapshots          = new MockRepository <Snapshot, int>();
            SnapshotSubmission = new MockRepository <SnapshotSubmission, int>(
                new List <SnapshotSubmission>()
            {
                new SnapshotSubmission()
                {
                    Id = FirstCalculatorSubmissionId,
                    CreatedDateTime = MockSnapshots.GetFirstCalculatorSnapshotTime()
                }
            });
            Generator = new SnapshotGenerator(new MockSnapshotDateConverter(), SnapshotSubmission,
                                              Snapshots, new MockSnapshotReportGenerate(), Students,
                                              new MockAbstractSyntaxClassTreeExtractor(),
                                              new MockAbstractSyntaxTreeGenerator());
            Data = new SubmissionData(Submission, Root)
            {
                Student = Student
            };
            GeneratorObj = new SnapshotGenerator.SnapshotGeneratorObj(Data, Assignment, Generator);
        }
Пример #8
0
 public void AreSnapshotsSame_ShouldReturnFalseForDifferentSnapshot()
 {
     Assert.IsFalse(GeneratorObj.AreSnapshotsTheSame(
                        Data.SnapshotSourceFileFullPath(MockSnapshots.GetThirdCalculatorSnapshotName(),
                                                        MockSnapshots.GetCalculatorFile()), MockSnapshots.GetCalculatorFile()));
 }
Пример #9
0
 public void AreSnapshotsSame_ShouldReturnTrueForSecondSnapshot()
 {
     Assert.IsTrue(GeneratorObj.AreSnapshotsTheSame(
                       Data.SnapshotSourceFileFullPath(MockSnapshots.GetSecondCalculatorSnapshotName(),
                                                       MockSnapshots.GetCalculatorFile()), MockSnapshots.GetCalculatorFile()));
 }