Ejemplo n.º 1
0
        public void MerchantDomainEventHandler_DeviceAddedToMerchantEvent_EventIsHandled()
        {
            DeviceAddedToMerchantEvent deviceAddedToMerchantEvent = TestData.DeviceAddedToMerchantEvent;

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

            MerchantDomainEventHandler eventHandler = new MerchantDomainEventHandler(estateReportingRepository.Object);

            Logger.Initialise(NullLogger.Instance);

            Should.NotThrow(async() => { await eventHandler.Handle(deviceAddedToMerchantEvent, CancellationToken.None); });
        }
Ejemplo n.º 2
0
        public void DeviceAddedToMerchantEvent_CanBeCreated_IsCreated()
        {
            DeviceAddedToMerchantEvent deviceAddedToMerchantEvent =
                new DeviceAddedToMerchantEvent(TestData.MerchantId, TestData.EstateId, TestData.DeviceId, TestData.DeviceIdentifier);

            deviceAddedToMerchantEvent.ShouldNotBeNull();
            deviceAddedToMerchantEvent.AggregateId.ShouldBe(TestData.MerchantId);
            deviceAddedToMerchantEvent.EventId.ShouldNotBe(Guid.Empty);
            deviceAddedToMerchantEvent.EstateId.ShouldBe(TestData.EstateId);
            deviceAddedToMerchantEvent.MerchantId.ShouldBe(TestData.MerchantId);
            deviceAddedToMerchantEvent.DeviceId.ShouldBe(TestData.DeviceId);
            deviceAddedToMerchantEvent.DeviceIdentifier.ShouldBe(TestData.DeviceIdentifier);
        }
        /// <summary>
        /// Adds the device.
        /// </summary>
        /// <param name="deviceId">The device identifier.</param>
        /// <param name="deviceIdentifier">The device identifier.</param>
        public void AddDevice(Guid deviceId,
                              String deviceIdentifier)
        {
            Guard.ThrowIfNullOrEmpty(deviceIdentifier, typeof(ArgumentNullException), "Device Identifier cannot be null or empty");

            this.EnsureMerchantHasBeenCreated();
            this.EnsureMerchantHasSpaceForDevice();
            // TODO: Reintroduce when merchant can request > 1 device
            //this.EnsureNotDuplicateDevice(deviceId, deviceIdentifier);

            DeviceAddedToMerchantEvent deviceAddedToMerchantEvent = new DeviceAddedToMerchantEvent(this.AggregateId, this.EstateId, deviceId, deviceIdentifier);

            this.ApplyAndAppend(deviceAddedToMerchantEvent);
        }
Ejemplo 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(DeviceAddedToMerchantEvent domainEvent,
                                              CancellationToken cancellationToken)
 {
     await this.EstateReportingRepository.AddMerchantDevice(domainEvent, cancellationToken);
 }
 /// <summary>
 /// Plays the event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 private void PlayEvent(DeviceAddedToMerchantEvent domainEvent)
 {
     this.Devices.Add(domainEvent.DeviceId, domainEvent.DeviceIdentifier);
 }