예제 #1
0
        private void OnPopupActivate(PopupActivateMessage message)
        {
            _command = message.Content.Item1;
            _score   = message.Content.Item2;

            IsActive = true;

            Text = string.Format(_command is AddScoreCommand ? CongsText : OopsText, _command.CommandName, _score);
        }
예제 #2
0
        public async System.Threading.Tasks.Task HandleAsync(ContestEndCommand command)
        {
            var newestSolutionsQuery = NewestSolutionsQuery.Create(command.ContestId);
            var solutions            = await _newestSolutionQueryHandler.HandleAsync(newestSolutionsQuery);

            foreach (var solutionId in solutions.SolutionIds)
            {
                var verifySolutionCommand = VerifySolutionCommand.Create(solutionId);
                await _verifySolutionCommandHandler.HandleAsync(verifySolutionCommand);

                var calculateScoreQuery  = CalculateScoreQuery.Create(solutionId);
                var calculateScoreResult = await _calculateScoreQueryHandler.HandleAsync(calculateScoreQuery);

                var changeScoreCommand = ChangeScoreCommand.Create(solutionId, calculateScoreResult.Score);
                await _changeScoreCommandHandler.HandleAsync(changeScoreCommand);
            }
        }
예제 #3
0
        public void SampleVerification_ExpectedScoreChangeInDataBase()
        {
            var givenContest = new Contest
            {
                Name   = "",
                Status = Contest.ContestState.InProgress
            };

            Context.Contests.Add(givenContest);
            var givenTask = new Task
            {
                Contest     = givenContest,
                Description = "",
                Name        = "",
            };

            Context.Tasks.Add(givenTask);
            var givenTest = new Test
            {
                ExpectedOutput = "expected-output",
                Input          = "given-input",
                Task           = givenTask
            };

            Context.Tests.Add(givenTest);
            var givenSolution = new Solution
            {
                SourceCode = "given-source-code",
                Language   = "java",
                Task       = givenTask
            };

            Context.Solutions.Add(givenSolution);
            Context.SaveChanges();

            ICommandHandler <ChangeScoreCommand> sut =
                new ChangeScoreCommandHandler(Context);

            int newScore = 2;
            var command  = ChangeScoreCommand.Create(givenSolution.Id, newScore);

            sut.HandleAsync(command).Wait();
            var solution = Context.Solutions.Find(givenSolution.Id);

            solution.PointCount.Should().Be(newScore);
        }
예제 #4
0
        private void OnPopupActivate(PopupActivateMessage message)
        {
            _command = message.Content.Item1;
            _score = message.Content.Item2;

            IsActive = true;

            Text = string.Format(_command is AddScoreCommand ? CongsText : OopsText, _command.CommandName, _score);
        }