Exemple #1
0
        public void Other_Systems_Are_Notified_After_A_Succcessful_Onboarding()
        {
            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.Deliver(new WelcomePackSentToCustomer {
                    CustomerName = customerName
                });
                fixture.ShouldHaveCompleted();
                bus.HasPublished <CustomerOnboarded>(
                    with: x => x.CustomerName == customerName,
                    because: "the saga should publishes an event notifying of the customer onboarding")
                .HasNotSentLocal <CustomerOnboardingOlaBreached>(
                    because: "the onboarding was successful");

                fixture.ShouldHaveCompleted();

                OnboardCustomerSagaData SagaDataShould(Predicate <OnboardCustomerSagaData> have, string because = null)
                {
                    return(fixture.SagaData <OnboardCustomerSaga, OnboardCustomerSagaData>().Should(have, because));
                }
            }
        }