public void when_reservation_accepted_then_routes_and_saves()
        {
            var pm = new RegistrationProcessManager
            {
                State                     = RegistrationProcessManager.ProcessState.AwaitingReservationConfirmation,
                ReservationId             = Guid.NewGuid(),
                ConferenceId              = Guid.NewGuid(),
                SeatReservationCommandId  = Guid.NewGuid(),
                ReservationAutoExpiration = DateTime.UtcNow.AddMinutes(10)
            };
            var context = new StubProcessManagerDataContext <RegistrationProcessManager> {
                Store = { pm }
            };
            var router = new RegistrationProcessManagerRouter(() => context);

            router.Handle(
                new Envelope <SeatsReserved>(
                    new SeatsReserved {
                SourceId = pm.ConferenceId, ReservationId = pm.ReservationId, ReservationDetails = new SeatQuantity[0]
            })
            {
                CorrelationId = pm.SeatReservationCommandId.ToString()
            });

            Assert.Equal(1, context.SavedProcesses.Count);
            Assert.True(context.DisposeCalled);
        }
        public void when_order_placed_then_routes_and_saves()
        {
            var context = new StubProcessManagerDataContext <RegistrationProcessManager>();
            var router  = new RegistrationProcessManagerRouter(() => context);

            router.Handle(new OrderPlaced {
                SourceId = Guid.NewGuid(), ConferenceId = Guid.NewGuid(), Seats = new SeatQuantity[0]
            });

            Assert.Equal(1, context.SavedProcesses.Count);
            Assert.True(context.DisposeCalled);
        }
        public void when_order_confirmed_received_then_routes_and_saves()
        {
            var pm = new RegistrationProcessManager {
                State   = RegistrationProcessManager.ProcessState.PaymentConfirmationReceived,
                OrderId = Guid.NewGuid(),
                ReservationAutoExpiration = DateTime.UtcNow.AddMinutes(10)
            };
            var context = new StubProcessManagerDataContext <RegistrationProcessManager> {
                Store = { pm }
            };
            var router = new RegistrationProcessManagerRouter(() => context);

            router.Handle(new OrderConfirmed {
                SourceId = pm.OrderId
            });

            Assert.Equal(1, context.SavedProcesses.Count);
            Assert.True(context.DisposeCalled);
        }
        public void when_order_updated_then_routes_and_saves()
        {
            var pm = new RegistrationProcessManager {
                State                     = RegistrationProcessManager.ProcessState.AwaitingReservationConfirmation,
                ReservationId             = Guid.NewGuid(),
                ConferenceId              = Guid.NewGuid(),
                ReservationAutoExpiration = DateTime.UtcNow.AddMinutes(10)
            };
            var context = new StubProcessManagerDataContext <RegistrationProcessManager> {
                Store = { pm }
            };
            var router = new RegistrationProcessManagerRouter(() => context);

            router.Handle(new OrderUpdated {
                SourceId = pm.OrderId, Seats = new SeatQuantity[0]
            });

            Assert.Equal(1, context.SavedProcesses.Count);
            Assert.True(context.DisposeCalled);
        }
        public void When_order_expired_then_routes_and_saves()
        {
            var pm = new RegistrationProcessManager {
                State                     = RegistrationProcessManager.ProcessState.AwaitingReservationConfirmation,
                ReservationId             = Guid.NewGuid(),
                OrderId                   = Guid.NewGuid(),
                ReservationAutoExpiration = DateTime.UtcNow.AddMinutes(10)
            };
            var context = new StubProcessManagerDataContext <RegistrationProcessManager> {
                Store = { pm }
            };

            var router = new RegistrationProcessManagerRouter(() => context);

            router.Handle(new Commands.ExpireRegistrationProcess {
                ProcessId = pm.Id
            });

            Assert.AreEqual(1, context.SavedProcesses.Count);
            Assert.IsTrue(context.DisposeCalled);
        }