public void GolfClubCreatedEvent_CanBeCreated_IsCreated()
        {
            GolfClubCreatedEvent golfClubCreatedEvent = GolfClubCreatedEvent.Create(GolfClubTestData.AggregateId,
                                                                                    GolfClubTestData.Name,
                                                                                    GolfClubTestData.AddressLine1,
                                                                                    GolfClubTestData.AddressLine2,
                                                                                    GolfClubTestData.Town,
                                                                                    GolfClubTestData.Region,
                                                                                    GolfClubTestData.PostalCode,
                                                                                    GolfClubTestData.TelephoneNumber,
                                                                                    GolfClubTestData.Website,
                                                                                    GolfClubTestData.EmailAddress);

            golfClubCreatedEvent.ShouldNotBeNull();
            golfClubCreatedEvent.AggregateId.ShouldBe(GolfClubTestData.AggregateId);
            golfClubCreatedEvent.Name.ShouldBe(GolfClubTestData.Name);
            golfClubCreatedEvent.AddressLine1.ShouldBe(GolfClubTestData.AddressLine1);
            golfClubCreatedEvent.AddressLine2.ShouldBe(GolfClubTestData.AddressLine2);
            golfClubCreatedEvent.Town.ShouldBe(GolfClubTestData.Town);
            golfClubCreatedEvent.Region.ShouldBe(GolfClubTestData.Region);
            golfClubCreatedEvent.PostalCode.ShouldBe(GolfClubTestData.PostalCode);
            golfClubCreatedEvent.TelephoneNumber.ShouldBe(GolfClubTestData.TelephoneNumber);
            golfClubCreatedEvent.Website.ShouldBe(GolfClubTestData.Website);
            golfClubCreatedEvent.EmailAddress.ShouldBe(GolfClubTestData.EmailAddress);
            golfClubCreatedEvent.EventCreatedDateTime.ShouldNotBe(DateTime.MinValue);
            golfClubCreatedEvent.EventId.ShouldNotBe(Guid.Empty);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the golf club.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="addressLine1">The address line1.</param>
        /// <param name="addressLine2">The address line2.</param>
        /// <param name="town">The town.</param>
        /// <param name="region">The region.</param>
        /// <param name="postalCode">The postal code.</param>
        /// <param name="telephoneNumber">The telephone number.</param>
        /// <param name="website">The website.</param>
        /// <param name="emailAddress">The email address.</param>
        public void CreateGolfClub(String name,
                                   String addressLine1,
                                   String addressLine2,
                                   String town,
                                   String region,
                                   String postalCode,
                                   String telephoneNumber,
                                   String website,
                                   String emailAddress)
        {
            // Now apply the business rules
            Guard.ThrowIfNullOrEmpty(name, typeof(ArgumentNullException), "A club must have a name to be created");
            Guard.ThrowIfNullOrEmpty(addressLine1, typeof(ArgumentNullException), "A club must have an Address line 1 to be created");
            Guard.ThrowIfNullOrEmpty(town, typeof(ArgumentNullException), "A club must have a town to be created");
            Guard.ThrowIfNullOrEmpty(region, typeof(ArgumentNullException), "A club must have a region to be created");
            Guard.ThrowIfNullOrEmpty(postalCode, typeof(ArgumentNullException), "A club must have a postal code to be created");
            Guard.ThrowIfNullOrEmpty(telephoneNumber, typeof(ArgumentNullException), "A club must have a telephone number to be created");

            this.CheckGolfClubHasNotAlreadyBeenCreated();

            // Now create the domain event
            GolfClubCreatedEvent golfClubCreatedEvent =
                GolfClubCreatedEvent.Create(this.AggregateId, name, addressLine1, addressLine2, town, region, postalCode, telephoneNumber, website, emailAddress);

            // Apply and Pend the event
            this.ApplyAndPend(golfClubCreatedEvent);
        }
Esempio n. 3
0
 /// <summary>
 /// Plays the event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 private void PlayEvent(GolfClubCreatedEvent domainEvent)
 {
     this.Name                = domainEvent.Name;
     this.AddressLine1        = domainEvent.AddressLine1;
     this.AddressLine2        = domainEvent.AddressLine2;
     this.Town                = domainEvent.Town;
     this.Region              = domainEvent.Region;
     this.PostalCode          = domainEvent.PostalCode;
     this.TelephoneNumber     = domainEvent.TelephoneNumber;
     this.Website             = domainEvent.Website;
     this.EmailAddress        = domainEvent.EmailAddress;
     this.HasBeenCreated      = true;
     this.MeasuredCourses     = new List <MeasuredCourse>();
     this.TournamentDivisions = new List <TournamentDivision>();
     this.MatchSecretarySecurityUserIdList = new List <Guid>();
 }
Esempio n. 4
0
 /// <summary>
 /// Handles the event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns></returns>
 private async Task HandleSpecificDomainEvent(GolfClubCreatedEvent domainEvent,
                                              CancellationToken cancellationToken)
 {
     await this.Manager.InsertGolfClubToReadModel(domainEvent, cancellationToken);
 }