/// <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.EnsureMerchantHasBeenCreated();

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

            this.ApplyAndAppend(securityUserAddedEvent);
        }
Exemplo n.º 2
0
        public void MerchantDomainEventHandler_SecurityUserAddedEvent_EventIsHandled()
        {
            SecurityUserAddedToMerchantEvent merchantSecurityUserAddedEvent = TestData.MerchantSecurityUserAddedEvent;

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

            MerchantDomainEventHandler eventHandler = new MerchantDomainEventHandler(estateReportingRepository.Object);

            Logger.Initialise(NullLogger.Instance);

            Should.NotThrow(async() => { await eventHandler.Handle(merchantSecurityUserAddedEvent, CancellationToken.None); });
        }
Exemplo n.º 3
0
        public void SecurityUserAddedEvent_CanBeCreated_IsCreated()
        {
            SecurityUserAddedToMerchantEvent securityUserAddedEvent = new SecurityUserAddedToMerchantEvent(TestData.MerchantId,
                                                                                                           TestData.EstateId,
                                                                                                           TestData.SecurityUserId,
                                                                                                           TestData.EstateUserEmailAddress);

            securityUserAddedEvent.ShouldNotBeNull();
            securityUserAddedEvent.AggregateId.ShouldBe(TestData.MerchantId);
            securityUserAddedEvent.MerchantId.ShouldBe(TestData.MerchantId);
            securityUserAddedEvent.EventId.ShouldNotBe(Guid.Empty);
            securityUserAddedEvent.EstateId.ShouldBe(TestData.EstateId);
            securityUserAddedEvent.SecurityUserId.ShouldBe(TestData.SecurityUserId);
            securityUserAddedEvent.EmailAddress.ShouldBe(TestData.EstateUserEmailAddress);
        }
Exemplo n.º 4
0
 /// <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(SecurityUserAddedToMerchantEvent domainEvent,
                                              CancellationToken cancellationToken)
 {
     await this.EstateReportingRepository.AddMerchantSecurityUser(domainEvent, cancellationToken);
 }
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        private void PlayEvent(SecurityUserAddedToMerchantEvent domainEvent)
        {
            SecurityUser securityUser = SecurityUser.Create(domainEvent.SecurityUserId, domainEvent.EmailAddress);

            this.SecurityUsers.Add(securityUser);
        }