public RunController(IDbContext context, ICompiler compiler, IRunner runner, Participant participant = null)
 {
     _context = context;
     _compiler = compiler;
     _runner = runner;
     _participant = participant == null ? GetCurrentParticipant() : participant;
 }
 public ScoresController(IDbContext context, ICompiler compiler, IRunner runner, Participant participant = null)
 {
     _context = context;
     _compiler = compiler;
     _runner = runner;
     _participant = participant ?? GetCurrentParticipant();
 }
        public void SetUp()
        {
            _contextMock = new Mock<IDbContext>();

            _compiler = new TestCompiler();
            _participant = new Participant{Email = "", Id = 12};
            _controller = new BuildController(_contextMock.Object, _compiler, _participant);
        }
        public void DeleteProgressWhenNoProgressIsStarted()
        {
            _contextMock = new Mock<IDbContext>();

            _participant = new Participant { Id = 1, Email = "", Scores = null, UserSetting = null, Progress = null };
            _controller = new ProgressController(_contextMock.Object, _participant);
            SetupControllerForTests(_controller);

            var request = _controller.Delete();
        }
        public static Score CreateScore(Assignment assignment, Participant participant, bool correctOutput, double timeDifference)
        {
            var score = new Score{
                Assignment = assignment,
                IsCorrectOutput = correctOutput,
                Participant = participant,
                TimeSpent = timeDifference
            };

            return score;
        }
        public CompilerResult CompileFromPlainText(Participant participant, string code)
        {
            var workingFolder = WorkingFolder.GetWorkingFolder(participant.Id);

            const string fileName = "Solution" + ".java";
            Directory.CreateDirectory(workingFolder);
            var filePath = Path.Combine(workingFolder, fileName);

            File.WriteAllText(filePath, code);
            return CompilerProcess.Compile(string.Format("\"{0}\"", filePath));
        }
        public void SetUp()
        {
            _contextMock = new Mock<IDbContext>();

            _compiler = new TestCompiler();
            _runner = new TestRunner();
            var scores = new Collection<Score> { };
            scores.Add(new Score { Assignment = new Assignment { Id = 1 } });
            _participant = new Participant { Id = 1, Email = "", Scores = scores, UserSetting = null };
            Progress progress = new Progress { Assignment = new Assignment { Id = 1, MaxSolveTime = 1000, RunCodeInput = "test", RunCodeOuput = "test" }, Id = 1, StartTime = DateTime.Now, Participant = _participant };
            _participant.Progress = progress;
            _controller = new ScoresController(_contextMock.Object, _compiler, _runner, _participant);
            MapperConfig.Configure();
        }
        public void PutProgressReturnsCreatedStatusCode()
        {
            _contextMock = new Mock<IDbContext>();
            var list = CreateSampleData(3);
            _contextMock.Setup(m => m.Assignments).Returns(list);
            _contextMock.Setup(m => m.Progresses);
            _participant = new Participant { Id = 1, Email = "", Scores = null, UserSetting = null, Progress = null };
            _controller = new ProgressController(_contextMock.Object, _participant);
            SetupControllerForTests(_controller);

            Progress progress = new Progress { Assignment = list.Find(1), Id = 2, Participant = _participant, StartTime = DateTime.Now };
            var result = _controller.Put(1, progress);
            Assert.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);
        }
 public void SetUp()
 {
     _contextMock = new Mock<IDbContext>();
     _controller = new ScoresController(_contextMock.Object);
     ICollection<Assignment> col = new Collection<Assignment>();
     var ass = new Assignment { Id = 1, Title = "Test", Scores = new Collection<Score>() };
     var participant = new Participant { Id = 1, Email = "vin" };
     ass.Scores.Add(new Score { Assignment = ass, Id = 1, IsCorrectOutput = true, Participant = participant, TimeSpent = 199 });
     col.Add(ass);
     Contest cont = new Contest{ Assignments = col, Id = 1, IsActive = true, Name = "Contest A" } ;
     _scoreCalc = new ParticipantScore(cont, participant);
     FakeDbSet<Contest> condb = new FakeDbSet<Contest>();
     condb.Add(cont);
     FakeDbSet<Participant> pardb = new FakeDbSet<Participant>();
     pardb.Add(participant);
     _leaderboard = new Leaderboard(condb, pardb);
 }
 public ParticipantScore(Contest contest, Participant participant)
 {
     Email = participant.Email;
     Name = participant.Name;
     Functie = participant.Functie;
     SetScore(contest, participant.Id);
 }
 public RunResult RunAndCheckInput(Participant participant)
 {
     return new RunResult { Error = "", Output = "Hello user:" + participant.Id, RunTime = 100 };
 }
 public RunResult RunAndCheckInput(Participant participant)
 {
     var argument = CreateRunArgument(participant);
     return RunnerProcess.Run(argument, participant.Progress.Assignment.RunCodeInput);
 }
 private string CreateRunArgument(Participant participant)
 {
     return "-cp " + GetFilePath(participant.Id) + " Solution";
 }
 public void SetUp()
 {
     _contextMock = new Mock<IDbContext>();
     _participant = new Participant { Id = 1, Email = "", Scores = null, UserSetting = null };
     Progress progress = new Progress { Assignment = new Assignment { Id = 1, MaxSolveTime = 1000 }, Id = 1, StartTime = DateTime.Now, Participant = _participant };
     _participant.Progress = progress;
     _controller = new ProgressController(_contextMock.Object, _participant);
     MapperConfig.Configure();
 }
 public RunResult Run(Participant participant)
 {
     var argument = CreateRunArgument(participant);
     return RunnerProcess.Run(argument);
 }
 public CompilerResult CompileFromPlainText(Participant participant, string code)
 {
     CompilerResult compResultTest = new CompilerResult { CompilationTime = 100, StandardError = "", StandardOutput = "Hello World!" };
     return compResultTest;
 }
 public AssignmentsController(IDbContext context, Participant participant = null)
 {
     _context = context;
     _participant = participant ?? GetCurrentParticipant();
 }
 public BuildController(IDbContext context, ICompiler compiler, Participant participant = null)
 {
     _context = context;
     _compiler = compiler;
     _participant = participant == null ? GetCurrentParticipant() : participant;
 }
 public ProgressController(IDbContext context, Participant participant = null)
 {
     _context = context;
     _participant = participant == null ? GetCurrentParticipant() : participant;
 }