Exemplo n.º 1
0
        public void If_The_Ola_Is_Breached_Then_Any_Placed_Sales_Call_Is_Cancelled()
        {
            var customerName = RandomName;
            var bus          = new FakeBus();

            using (var fixture = SagaFixture.For(() => new OnboardCustomerSaga(bus)))
            {
                fixture.Deliver(new OnboardCustomer {
                    CustomerName = customerName
                });
                fixture.Deliver(new CustomerAccountCreated {
                    CustomerName = customerName
                });
                bus.HasSentLocal <ScheduleASalesCall>(
                    with: x => x.CustomerName == customerName,
                    because: "a sales call is scheduled after the account is created");

                fixture.Deliver(new VerifyCustomerOnboardingOla {
                    CustomerName = customerName
                });

                fixture.ShouldHaveCompleted();
                bus.HasSentLocal <CancellSalesCall>(
                    with: x => x.CustomerName == customerName,
                    because: "any scheduled sales call is cancelled after an OLA breach");
            }
        }
Exemplo n.º 2
0
        public void Onboarding_Causes_An_Account_To_Be_Created_For_The_Customer()
        {
            var customerName = RandomName;
            var bus          = new FakeBus();

            using (var fixture = SagaFixture.For(() => new OnboardCustomerSaga(bus)))
            {
                fixture.Deliver(new OnboardCustomer {
                    CustomerName = customerName
                });
                fixture.SagaDataShould(
                    have: x => x.CustomerName == customerName,
                    because: "store the customer name")
                .SagaDataIsNotComplete();
                bus.HasSentLocal <CreateCustomerAccount>(
                    with: x => x.CustomerName == customerName,
                    because: "it should initiate account creation"
                    );


                fixture.Deliver(new CustomerAccountCreated {
                    CustomerName = customerName
                });
                fixture.SagaDataShould(
                    have: x => x.AccountCreated,
                    because: "it should remember the account has been created")
                .SagaDataIsNotComplete();

                fixture.ShouldNotHaveCompleted();
            }
        }
Exemplo n.º 3
0
        public void The_Sales_Team_Will_Set_Up_A_Call_With_The_Customer_After_Their_Account_Has_Been_Created()
        {
            var customerName = RandomName;
            var bus          = new FakeBus();

            using (var fixture = SagaFixture.For(() => new OnboardCustomerSaga(bus)))
            {
                fixture.Deliver(new OnboardCustomer {
                    CustomerName = customerName
                });
                fixture.Deliver(new CustomerAccountCreated {
                    CustomerName = customerName
                });
                fixture.SagaDataShould(
                    have: x => x.AccountCreated,
                    because: "it should remember the account has been created")
                .SagaDataIsNotComplete();

                bus.HasSentLocal <ScheduleASalesCall>(
                    with: x => x.CustomerName == customerName,
                    because: "a sales call is scheduled after the account is created");

                fixture.ShouldNotHaveCompleted();
            }
        }
Exemplo n.º 4
0
        public void If_The_Ola_Is_Breached_Then_The_Service_Desk_Takes_Over_The_Process()
        {
            var customerName = RandomName;
            var bus          = new FakeBus();

            using (var fixture = SagaFixture.For(() => new OnboardCustomerSaga(bus)))
            {
                fixture.Deliver(new OnboardCustomer {
                    CustomerName = customerName
                });
                bus.HasDeferredLocal <VerifyCustomerOnboardingOla>(
                    with: x => x.CustomerName == customerName,
                    because: "it should start tracking the OLA");

                fixture.Deliver(new VerifyCustomerOnboardingOla {
                    CustomerName = customerName
                });

                fixture.ShouldHaveCompleted();
                bus.HasSentLocal <CustomerOnboardingOlaBreached>(
                    with: x => x.CustomerName == customerName,
                    because: "the service desk should be notified of the failed onboarding");
            }
        }