示例#1
0
        public static HandicapCalculationProcessAggregate GetRunningHandicapCalculationProcessAggregate()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessAggregate.Create(HandicapCalculationProcessTestData.AggregateId);

            handicapCalculationProcessAggregate.StartHandicapCalculationProcess(TournamentTestData.GetCompletedTournamentAggregateWithCSSCalculatedAggregate(), HandicapCalculationProcessTestData.StartedDateTime);
            handicapCalculationProcessAggregate.UpdateProcessToRunning(HandicapCalculationProcessTestData.RunningDateTime);
            return(handicapCalculationProcessAggregate);
        }
示例#2
0
        public void HandicapCalculationProcessAggregate_StartHandicapCalculationProcess_ProcessRecordedAsStarted()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetEmptyHandicapCalculationProcessAggregate();

            handicapCalculationProcessAggregate.StartHandicapCalculationProcess(TournamentTestData.GetCompletedTournamentAggregateWithCSSCalculatedAggregate(), HandicapCalculationProcessTestData.StartedDateTime);

            handicapCalculationProcessAggregate.AggregateId.ShouldBe(handicapCalculationProcessAggregate.AggregateId);
            handicapCalculationProcessAggregate.StartedDateTime.ShouldBe(handicapCalculationProcessAggregate.StartedDateTime);
            handicapCalculationProcessAggregate.Status.ShouldBe(HandicapProcessStatus.Started);
        }
示例#3
0
        public void HandicapCalculationProcessAggregate_StartHandicapCalculationProcess_AlreadyErrored_ErrorThrown()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetErroredHandicapCalculationProcessAggregate();

            Should.Throw <InvalidOperationException>(() =>
            {
                handicapCalculationProcessAggregate.StartHandicapCalculationProcess(TournamentTestData
                                                                                    .GetCompletedTournamentAggregateWithCSSCalculatedAggregate(),
                                                                                    HandicapCalculationProcessTestData
                                                                                    .StartedDateTime);
            });
        }
        public void HandicapCalculationCommandHandler_HandleCommand_StartHandicapCalculationProcessForTournamentCommand_CommandHandled()
        {
            Mock <IAggregateRepository <HandicapCalculationProcessAggregate> > handicapCalculationProcessRepository = new Mock <IAggregateRepository <HandicapCalculationProcessAggregate> >();

            handicapCalculationProcessRepository.Setup(h => h.GetLatestVersion(It.IsAny <Guid>(), CancellationToken.None))
            .ReturnsAsync(HandicapCalculationProcessTestData.GetEmptyHandicapCalculationProcessAggregate());
            Mock <IAggregateRepository <TournamentAggregate> > tournamentRepository = new Mock <IAggregateRepository <TournamentAggregate> >();

            tournamentRepository.Setup(t => t.GetLatestVersion(It.IsAny <Guid>(), CancellationToken.None))
            .ReturnsAsync(TournamentTestData.GetCompletedTournamentAggregateWithCSSCalculatedAggregate());

            HandicapCalculationCommandHandler handler = new HandicapCalculationCommandHandler(handicapCalculationProcessRepository.Object,
                                                                                              tournamentRepository.Object);

            StartHandicapCalculationProcessForTournamentCommand command = HandicapCalculationProcessTestData.GetStartHandicapCalculationProcessForTournamentCommand();

            Should.NotThrow(async() => { await handler.Handle(command, CancellationToken.None); });
        }