public void MeasuredCourseAddedEvent_CanBeCreated_IsCreated() { MeasuredCourseAddedEvent measuredCourseAddedEvent = MeasuredCourseAddedEvent.Create(GolfClubTestData.AggregateId, GolfClubTestData.MeasuredCourseId, GolfClubTestData.MeasuredCourseName, GolfClubTestData.TeeColour, GolfClubTestData.StandardScratchScore); measuredCourseAddedEvent.ShouldNotBeNull(); measuredCourseAddedEvent.AggregateId.ShouldBe(GolfClubTestData.AggregateId); measuredCourseAddedEvent.EventCreatedDateTime.ShouldNotBe(DateTime.MinValue); measuredCourseAddedEvent.EventId.ShouldNotBe(Guid.Empty); measuredCourseAddedEvent.MeasuredCourseId.ShouldBe(GolfClubTestData.MeasuredCourseId); measuredCourseAddedEvent.Name.ShouldBe(GolfClubTestData.MeasuredCourseName); measuredCourseAddedEvent.TeeColour.ShouldBe(GolfClubTestData.TeeColour); measuredCourseAddedEvent.StandardScratchScore.ShouldBe(GolfClubTestData.StandardScratchScore); }
/// <summary> /// Adds the measured course. /// </summary> /// <param name="measuredCourse">The measured course.</param> public void AddMeasuredCourse(MeasuredCourseDataTransferObject measuredCourse) { // Apply the business rules here // Check club has been created this.CheckHasGolfClubAlreadyBeenCreated(); // Check for a duplicate measured course addition this.CheckNotDuplicateMeasuredCourse(measuredCourse); // Validate the measured course data this.ValidateMeasuredCourse(measuredCourse); // Now apply and pend the required events // First the measured course added event MeasuredCourseAddedEvent measuredCourseAddedEvent = MeasuredCourseAddedEvent.Create(this.AggregateId, measuredCourse.MeasuredCourseId, measuredCourse.Name, measuredCourse.TeeColour, measuredCourse.StandardScratchScore); this.ApplyAndPend(measuredCourseAddedEvent); // Now add an event for each hole foreach (HoleDataTransferObject holeDataTransferObject in measuredCourse.Holes) { HoleAddedToMeasuredCourseEvent holeAddedToMeasuredCourseEvent = HoleAddedToMeasuredCourseEvent.Create(this.AggregateId, measuredCourse.MeasuredCourseId, holeDataTransferObject.HoleNumber, holeDataTransferObject.LengthInYards, holeDataTransferObject.LengthInMeters, holeDataTransferObject.Par, holeDataTransferObject.StrokeIndex); this.ApplyAndPend(holeAddedToMeasuredCourseEvent); } }