Пример #1
0
        public async Task HandleAsync(IReadOnlyCollection <IDomainEvent> domainEvents, CancellationToken cancellationToken)
        {
            var evt = new OrderCommittedEvent
            {
                Id    = "1",
                Name  = "order",
                Price = 10
            };

            await _busControl.Publish(evt, cancellationToken);

            foreach (var domainEvent in domainEvents)
            {
                var e = domainEvent.GetAggregateEvent();
                await _busControl.Publish(e, cancellationToken);
            }
        }
Пример #2
0
        public async void WhenPublishOrderCommittedEventShouldUpdateOrderState()
        {
            //Arrange
            var evt = new OrderCommittedEvent
            {
                Id    = "1",
                Name  = "order",
                Price = 10
            };

            //Act
            await HostedService.StartAsync(CancellationToken.None);

            await _bus.Publish(evt);

            await HostedService.StopAsync(CancellationToken.None);

            //Assert
            OrderState.Name.Should().Be(evt.Name);
            OrderState.Price.Should().Be(evt.Price);
        }