public async Task HandlerShouldAddOrder()
        {
            // Arrange
            var expectedPlayer = new BrokerPlayer {
                PlayerId = Guid.NewGuid()
            };
            var expectedOrder = new BrokerOrder
            {
                OrderId = Guid.NewGuid(),
                ItemId  = Guid.NewGuid().ToString(),
            };

            _state.Players.Add(expectedPlayer.PlayerId, expectedPlayer);

            // Act
            await _handler.Handle(new OrderCreatedEvent(expectedOrder.OrderId, expectedPlayer)
            {
                ItemId = expectedOrder.ItemId,
            });

            // Assert
            Assert.Equal(expectedOrder.OrderId, _state.Orders.Values.Single().OrderId);
            Assert.Equal(expectedOrder.ItemId, _state.Orders.Values.Single().ItemId);
            Assert.Equal(OrderState.Active, _state.Orders.Values.Single().State);
            Assert.Same(expectedPlayer, _state.Orders.Values.Single().Owner);
        }
        public void when_order_totals_calculated_then_updates_order_total()
        {
            var e = new OrderExpired {
                SourceId = placed.SourceId
            };

            sut.Handle(e);

            var order = FindOrder(e.SourceId);

            Assert.Null(order);
        }
        public given_an_order()
        {
            placed = new OrderPlaced {
                ConferenceId = Guid.NewGuid(),
                SourceId     = Guid.NewGuid(),
                AccessCode   = "asdf"
            };

            sut = new OrderEventHandler(() => new ConferenceContext());
            sut.Handle(placed);
        }
Exemple #4
0
            public void Test()
            {
                OrderView orderView = new OrderView();
                var       handler   = new OrderEventHandler(orderView);

                handler.Handle(new OrderCreated(1.MakeGuid()));
                handler.Handle(new OrderLineAdded(1.MakeGuid(), new OrderLine(3, "MyProduct")));

                var view = new OrderView();

                view.GetAll().Single().ShouldBeEquivalentTo(new OrderDto()
                {
                    Id         = 1.MakeGuid(),
                    OrderLines = new []
                    {
                        new OrderLineDto()
                        {
                            Quantity    = 3,
                            ProductName = "MyProduct"
                        }
                    }
                });
            }
        public void when_order_placed_then_creates_order_entity()
        {
            var e = new OrderPlaced {
                ConferenceId = Guid.NewGuid(),
                SourceId     = Guid.NewGuid(),
                AccessCode   = "asdf"
            };

            sut.Handle(e);

            using (var context = new ConferenceContext()) {
                var order = context.Orders.Find(e.SourceId);

                Assert.NotNull(order);
            }
        }