/// <summary>
        /// Adjusts the handicap.
        /// </summary>
        /// <param name="handicapAdjustmentDataTransferObject">The handicap adjustment data transfer object.</param>
        /// <param name="tournamentId">The tournament identifier.</param>
        /// <param name="golfClubId">The golf club identifier.</param>
        /// <param name="measuredCourseId">The measured course identifier.</param>
        /// <param name="scoreDate">The score date.</param>
        public void AdjustHandicap(HandicapAdjustmentDataTransferObject handicapAdjustmentDataTransferObject,
                                   Guid tournamentId,
                                   Guid golfClubId,
                                   Guid measuredCourseId,
                                   DateTime scoreDate)
        {
            Guard.ThrowIfNull(handicapAdjustmentDataTransferObject, typeof(ArgumentNullException), "Handicap Adjustment details must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidGuid(tournamentId, typeof(ArgumentNullException), "Tournament Id must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidGuid(golfClubId, typeof(ArgumentNullException), "Golf Club Id must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidGuid(measuredCourseId, typeof(ArgumentNullException), "Measured Course Id must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidDate(scoreDate, typeof(ArgumentNullException), "Score Date must be provided to adjust a players handicap");

            this.CheckIfPlayerHasBeenRegistered();

            this.CheckNotDuplicateHandicapAdjustment(handicapAdjustmentDataTransferObject, tournamentId, golfClubId, measuredCourseId, scoreDate);

            HandicapAdjustedEvent handicapAdjustedEvent = HandicapAdjustedEvent.Create(this.AggregateId,
                                                                                       handicapAdjustmentDataTransferObject.NumberOfStrokesBelowCss,
                                                                                       handicapAdjustmentDataTransferObject.AdjustmentValuePerStroke,
                                                                                       handicapAdjustmentDataTransferObject.TotalAdjustment,
                                                                                       tournamentId,
                                                                                       golfClubId,
                                                                                       measuredCourseId,
                                                                                       scoreDate);

            this.ApplyAndPend(handicapAdjustedEvent);
        }
Ejemplo n.º 2
0
 public static HandicapAdjustedEvent GetHandicapAdjustedEvent()
 {
     return(HandicapAdjustedEvent.Create(PlayerTestData.AggregateId,
                                         PlayerTestData.NumberOfStrokesBelowCss,
                                         PlayerTestData.AdjustmentValuePerStroke,
                                         PlayerTestData.TotalAdjustment,
                                         PlayerTestData.TournamentId,
                                         PlayerTestData.GolfClubId,
                                         PlayerTestData.MeasuredCourseId,
                                         PlayerTestData.ScoreDate));
 }
        public void HandicapAdjustedEvent_CanBeCreated_IsCreated()
        {
            HandicapAdjustedEvent handicapAdjustedEvent = HandicapAdjustedEvent.Create(PlayerTestData.AggregateId, PlayerTestData.NumberOfStrokesBelowCss,
                                                                                       PlayerTestData.AdjustmentValuePerStroke, PlayerTestData.TotalAdjustment,
                                                                                       PlayerTestData.TournamentId, PlayerTestData.GolfClubId,
                                                                                       PlayerTestData.MeasuredCourseId, PlayerTestData.ScoreDate);

            handicapAdjustedEvent.ShouldNotBeNull();
            handicapAdjustedEvent.AggregateId.ShouldBe(PlayerTestData.AggregateId);
            handicapAdjustedEvent.EventId.ShouldNotBe(Guid.Empty);
            handicapAdjustedEvent.EventCreatedDateTime.ShouldNotBe(DateTime.MinValue);
            handicapAdjustedEvent.NumberOfStrokesBelowCss.ShouldBe(PlayerTestData.NumberOfStrokesBelowCss);
            handicapAdjustedEvent.AdjustmentValuePerStroke.ShouldBe(PlayerTestData.AdjustmentValuePerStroke);
            handicapAdjustedEvent.TotalAdjustment.ShouldBe(PlayerTestData.TotalAdjustment);
            handicapAdjustedEvent.TournamentId.ShouldBe(PlayerTestData.TournamentId);
            handicapAdjustedEvent.GolfClubId.ShouldBe(PlayerTestData.GolfClubId);
            handicapAdjustedEvent.MeasuredCourseId.ShouldBe(PlayerTestData.MeasuredCourseId);
            handicapAdjustedEvent.ScoreDate.ShouldBe(PlayerTestData.ScoreDate);
        }