/// <summary>
        /// Adds the security user.
        /// </summary>
        /// <param name="securityUserId">The security user identifier.</param>
        /// <param name="emailAddress">The email address.</param>
        public void AddSecurityUser(Guid securityUserId,
                                    String emailAddress)
        {
            this.CheckEstateHasBeenCreated();

            SecurityUserAddedToEstateEvent securityUserAddedEvent = new SecurityUserAddedToEstateEvent(this.AggregateId, securityUserId, emailAddress);

            this.ApplyAndAppend(securityUserAddedEvent);
        }
        public void EstateDomainEventHandler_SecurityUserAddedEvent_EventIsHandled()
        {
            SecurityUserAddedToEstateEvent securityUserAddedEvent = TestData.EstateSecurityUserAddedEvent;

            Mock <IEstateReportingRepository> estateReportingRepository = new Mock <IEstateReportingRepository>();

            EstateDomainEventHandler eventHandler = new EstateDomainEventHandler(estateReportingRepository.Object);

            Logger.Initialise(NullLogger.Instance);

            Should.NotThrow(async() => { await eventHandler.Handle(securityUserAddedEvent, CancellationToken.None); });
        }
        public void SecurityUserAddedEvent_CanBeCreated_IsCreated()
        {
            SecurityUserAddedToEstateEvent securityUserAddedEvent = new SecurityUserAddedToEstateEvent(TestData.EstateId,
                                                                                                       TestData.SecurityUserId,
                                                                                                       TestData.EstateUserEmailAddress);

            securityUserAddedEvent.ShouldNotBeNull();
            securityUserAddedEvent.AggregateId.ShouldBe(TestData.EstateId);
            securityUserAddedEvent.EventId.ShouldNotBe(Guid.Empty);
            securityUserAddedEvent.EstateId.ShouldBe(TestData.EstateId);
            securityUserAddedEvent.SecurityUserId.ShouldBe(TestData.SecurityUserId);
            securityUserAddedEvent.EmailAddress.ShouldBe(TestData.EstateUserEmailAddress);
        }
 /// <summary>
 /// Handles the specific domain event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 private async Task HandleSpecificDomainEvent(SecurityUserAddedToEstateEvent domainEvent,
                                              CancellationToken cancellationToken)
 {
     await this.EstateReportingRepository.AddEstateSecurityUser(domainEvent, cancellationToken);
 }
        private void PlayEvent(SecurityUserAddedToEstateEvent domainEvent)
        {
            SecurityUser securityUser = SecurityUser.Create(domainEvent.SecurityUserId, domainEvent.EmailAddress);

            this.SecurityUsers.Add(securityUser);
        }