/// <summary> /// Registers the specified first name. /// </summary> /// <param name="firstName">The first name.</param> /// <param name="middleName">Name of the middle.</param> /// <param name="lastName">The last name.</param> /// <param name="gender">The gender.</param> /// <param name="dateOfBirth">The date of birth.</param> /// <param name="exactHandicap">The exact handicap.</param> /// <param name="emailAddress">The email address.</param> public void Register(String firstName, String middleName, String lastName, String gender, DateTime dateOfBirth, Decimal exactHandicap, String emailAddress) { // Validate the registration details Guard.ThrowIfNullOrEmpty(firstName, typeof(ArgumentNullException), "A first name is required to register a player"); Guard.ThrowIfNullOrEmpty(lastName, typeof(ArgumentNullException), "A last name is required to register a player"); Guard.ThrowIfNullOrEmpty(gender, typeof(ArgumentNullException), "A gender is required to register a player"); Guard.ThrowIfNullOrEmpty(emailAddress, typeof(ArgumentNullException), "An email address is required to register a player"); this.ValidateGender(gender); this.ValidateDateOfBirth(dateOfBirth); this.ValidateHandicap(exactHandicap); this.CheckIfPlayerAlreadyRegistered(); // Create the Player Registered domain event PlayerRegisteredEvent playerRegisteredEvent = PlayerRegisteredEvent.Create(this.AggregateId, firstName, middleName, lastName, gender, dateOfBirth, exactHandicap, emailAddress); // Apply and pend this.ApplyAndPend(playerRegisteredEvent); // Create the Opening Handicap Added domain event OpeningExactHandicapAddedEvent openingExactHandicapAddedEvent = OpeningExactHandicapAddedEvent.Create(this.AggregateId, exactHandicap); // Apply and pend this.ApplyAndPend(openingExactHandicapAddedEvent); }
public void OpeningExactHandicapAddedEvent_CanBeCreated_IsCreated() { OpeningExactHandicapAddedEvent openingExactHandicapAddedEvent = OpeningExactHandicapAddedEvent.Create(PlayerTestData.AggregateId, PlayerTestData.ExactHandicap); openingExactHandicapAddedEvent.ShouldNotBeNull(); openingExactHandicapAddedEvent.AggregateId.ShouldBe(PlayerTestData.AggregateId); openingExactHandicapAddedEvent.EventId.ShouldNotBe(Guid.Empty); openingExactHandicapAddedEvent.EventCreatedDateTime.ShouldNotBe(DateTime.MinValue); openingExactHandicapAddedEvent.ExactHandicap.ShouldBe(PlayerTestData.ExactHandicap); }
/// <summary> /// Plays the event. /// </summary> /// <param name="openingExactHandicapAddedEvent">The opening handicap added event.</param> private void PlayEvent(OpeningExactHandicapAddedEvent openingExactHandicapAddedEvent) { this.ExactHandicap = openingExactHandicapAddedEvent.ExactHandicap; this.PlayingHandicap = this.CalculatePlayingHandicap(this.ExactHandicap); this.HandicapCategory = this.CalculateHandicapCategory(this.PlayingHandicap); }