示例#1
0
        public void GetLastSnapshotOrDefault_ShouldReturnNull()
        {
            var snapshot = new SnapshotGenerator.SnapshotGeneratorObj(Data,
                                                                      new Assignment()
            {
                Filename = "RandomFile.hpp",
                Id       = 100
            }, Generator);

            Assert.IsNull(snapshot.LastSnapshot);
        }
示例#2
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);
        }