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"); } }
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(); } }
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(); } }
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"); } }