Ejemplo n.º 1
0
        public void HandicapCalculationProcessAggregate_UpdateProcessToErrored_AlreadyCompleted_ErrorThrown()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate =
                HandicapCalculationProcessTestData.GetCompletedHandicapCalculationProcessAggregate();

            Should.Throw <InvalidOperationException>(() =>
            {
                handicapCalculationProcessAggregate.UpdateProcessToErrored(HandicapCalculationProcessTestData.ErroredDateTime,
                                                                           HandicapCalculationProcessTestData.ErrorMessage);
            });
        }
        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); });
        }
Ejemplo n.º 3
0
        public void HandicapCalculationProcessAggregate_StartHandicapCalculationProcess_TournamentScoresNotPublished()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetEmptyHandicapCalculationProcessAggregate();

            Should.Throw <InvalidOperationException>(() =>
            {
                handicapCalculationProcessAggregate.StartHandicapCalculationProcess(TournamentTestData
                                                                                    .GetCompletedTournamentAggregate(),
                                                                                    HandicapCalculationProcessTestData
                                                                                    .StartedDateTime);
            });
        }
Ejemplo n.º 4
0
        public void HandicapCalculationProcessAggregate_StartHandicapCalculationProcess_AlreadyErrored_ErrorThrown()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetErroredHandicapCalculationProcessAggregate();

            Should.Throw <InvalidOperationException>(() =>
            {
                handicapCalculationProcessAggregate.StartHandicapCalculationProcess(TournamentTestData
                                                                                    .GetCompletedTournamentAggregateWithCSSCalculatedAggregate(),
                                                                                    HandicapCalculationProcessTestData
                                                                                    .StartedDateTime);
            });
        }
Ejemplo n.º 5
0
        public void HandicapCalculationProcessAggregate_UpdateProcessToErrored_ProcessSetToErrored()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetRunningHandicapCalculationProcessAggregate();

            handicapCalculationProcessAggregate.UpdateProcessToErrored(HandicapCalculationProcessTestData.ErroredDateTime, HandicapCalculationProcessTestData.ErrorMessage);

            handicapCalculationProcessAggregate.AggregateId.ShouldBe(handicapCalculationProcessAggregate.AggregateId);
            handicapCalculationProcessAggregate.StartedDateTime.ShouldBe(handicapCalculationProcessAggregate.StartedDateTime);
            handicapCalculationProcessAggregate.RunningDateTime.ShouldBe(handicapCalculationProcessAggregate.RunningDateTime);
            handicapCalculationProcessAggregate.ErroredDateTime.ShouldBe(handicapCalculationProcessAggregate.ErroredDateTime);
            handicapCalculationProcessAggregate.ErrorMessage.ShouldBe(handicapCalculationProcessAggregate.ErrorMessage);
            handicapCalculationProcessAggregate.Status.ShouldBe(HandicapProcessStatus.Errored);
        }
Ejemplo n.º 6
0
        public void HandicapCalculationProcessAggregate_UpdateProcessToComplete_NotRunning_ErrorThrown()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetStartedHandicapCalculationProcessAggregate();

            Should.Throw <InvalidOperationException>(() =>
            {
                handicapCalculationProcessAggregate.UpdateProcessToComplete(HandicapCalculationProcessTestData
                                                                            .CompletedDateTime);
            });
        }
Ejemplo n.º 7
0
        public void HandicapCalculationProcessAggregate_UpdateProcessToComplete_ProcessSetToCompleted()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetRunningHandicapCalculationProcessAggregate();

            handicapCalculationProcessAggregate.UpdateProcessToComplete(HandicapCalculationProcessTestData.CompletedDateTime);

            handicapCalculationProcessAggregate.AggregateId.ShouldBe(handicapCalculationProcessAggregate.AggregateId);
            handicapCalculationProcessAggregate.StartedDateTime.ShouldBe(handicapCalculationProcessAggregate.StartedDateTime);
            handicapCalculationProcessAggregate.RunningDateTime.ShouldBe(handicapCalculationProcessAggregate.RunningDateTime);
            handicapCalculationProcessAggregate.CompletedDateTime.ShouldBe(handicapCalculationProcessAggregate.CompletedDateTime);
            handicapCalculationProcessAggregate.Status.ShouldBe(HandicapProcessStatus.Completed);
        }
Ejemplo n.º 8
0
        public void HandicapCalculationProcessAggregate_UpdateProcessToRunning_AlreadyErrored_ErrorThrown()
        {
            HandicapCalculationProcessAggregate handicapCalculationProcessAggregate = HandicapCalculationProcessTestData.GetErroredHandicapCalculationProcessAggregate();

            Should.Throw <InvalidOperationException>(() =>
            {
                handicapCalculationProcessAggregate.UpdateProcessToRunning(HandicapCalculationProcessTestData
                                                                           .RunningDateTime);
            });
        }
Ejemplo n.º 9
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);
        }