Пример #1
0
 public void creating_new_car_with_valid_state_should_success() =>
 CommandScenarioFor <CarState> .With(
     FakeCar.State
     )
 .GivenNone()
 .WhenNone()
 .ThenNone()
 .Assert(s => s.Should().NotBeNull());
        public void Should_succes_when_order_cancelled()
        {
            var existingOrder = FakeOrder;

            CommandScenarioFor <OrderState> .With
            (
                existingOrder
            )
            .When(s => Order.CancelOrder(s))
            .Then(new OrderCancelledEvent(existingOrder.Id.ToString()))
            .Assert();
        }
Пример #3
0
        public void renew_existing_car_model_above_2019_should_throw()
        {
            var fakeCar  = FakeCar;
            var fakeYear = 2020;

            CommandScenarioFor <CarState> .With(
                fakeCar.State
                )
            .GivenNone()
            .When(state => Car.RenewModel(state, fakeYear, _carPolicy))
            .Throws(new Exception("model cannot be above than 2019"))
            .Assert();
        }
Пример #4
0
        public void renew_existing_car_model_should_success()
        {
            var fakeCar  = FakeCar;
            var fakeYear = 2014;

            CommandScenarioFor <CarState> .With(
                fakeCar.State
                )
            .GivenNone()
            .When(state => Car.RenewModel(state, fakeYear, _carPolicy))
            .Then(new CarModelRenewedEvent(fakeCar.State.Id, fakeYear))
            .Assert();
        }
Пример #5
0
        public void change_existing_car_name_should_success()
        {
            var fakeCar  = FakeCar;
            var fakeName = "Mercedes";

            CommandScenarioFor <CarState> .With(
                fakeCar.State
                )
            .GivenNone()
            .When(state => Car.ChangeName(state, fakeName))
            .Then(new CarNameChangedEvent(fakeCar.State.Id, fakeName))
            .Assert();
        }
        public void Should_succes_when_order_item_added()
        {
            var existingOrder   = FakeOrder;
            var fakeProductId   = new ProductId(Guid.NewGuid().ToString());
            var fakeOrderItemId = OrderItemId.New;
            var unitPrice       = 100;
            var discount        = 10;

            CommandScenarioFor <OrderState> .With
            (
                existingOrder
            )
            .When(s => Order.AddOrderItem(s, fakeOrderItemId, fakeProductId, unitPrice, discount))
            .Then(new OrderItemAddedEvent(fakeOrderItemId, existingOrder.Id, fakeProductId, unitPrice, discount))
            .Assert();
        }
        public void Should_success_when_order_created()
        {
            var      fakeOrderId = OrderId.New;
            var      fakeBuyerId = CustomerId.New;
            var      fakeCity    = "Amsterdam";
            var      fakeStreet  = "Fake Street";
            DateTime now         = SystemClock.Now();

            var newOrder = Order.Create(fakeOrderId, fakeBuyerId, fakeCity, fakeStreet, () => now);

            CommandScenarioFor <OrderState> .With
                (newOrder.State)
            .WhenNone()
            .Then(new OrderStartedEvent(fakeOrderId, fakeBuyerId, fakeCity, fakeStreet, now))
            .Assert();
        }
        public void Should_throw_when_order_shipped_without_paid_state()
        {
            var order = FakeOrder;
            var moq   = new Mock <IOrderPolicy>();

            moq.Setup(p => p.Apply(It.IsAny <OrderShouldBePaidBeforeShip>()))
            .Throws <OrderNotPaidYetException>();

            IOrderPolicy policy = moq.Object;

            CommandScenarioFor <OrderState> .With
            (
                order
            )
            .When(s => Order.ShipOrder(order, policy))
            .Throws(typeof(OrderNotPaidYetException))
            .Assert();
        }