Ejemplo n.º 1
0
        public async Task ItShouldContinueWithEvents()
        {
            _snapshots
            .Load <Shopping>("customerId", "messageId")
            .Returns(Task.FromResult(new Snapshot(
                                         -1,
                                         "customerId",
                                         new Shopping()
                                         )));
            _events
            .Load <Shopping>("customerId", "messageId", -1)
            .Returns(new [] {
                new Envelope(
                    "customerId",
                    "Shopping",
                    0,
                    new ProductChosen("customerId", "productId")
                    )
            }.ToAsync());

            await Should.ThrowAsync <ShouldAssertException>(async() =>
                                                            await new CommandHandler <Shopping>(_events, _snapshots, "customerId")
                                                            .Handle(new ChooseProduct("customerId", "productId"), "messageId"));

            await _events
            .DidNotReceive()
            .Append <Shopping>(Arg.Any <IEnumerable <Envelope> >());

            await _snapshots
            .DidNotReceive()
            .Save <Shopping>(Arg.Any <Snapshot>());
        }