Beispiel #1
0
    public void Setup()
    {
        saga = new GracePeriodForAcceptingRebookings
        {
            Data = new GracePeriodForAcceptingRebookingsData()
        };
        context = new TestableMessageHandlerContext();

        rebookingWasProposed = new RebookingWasProposed(
            bookingReferenceId,
            "Aircraft type was changed from Boeing 787 to Boeing 777");
    }
Beispiel #2
0
    public async Task ShouldNotNotifyCustomers()
    {
        await saga.Handle(proposedRebookingWasRejected, context);

        var rebookingWasProposed = new RebookingWasProposed(
            bookingReferenceId,
            "Aircraft type was changed from Boeing 787 to Boeing 777");

        await saga.Handle(rebookingWasProposed, context);

        Assert.IsTrue(saga.Completed);
        Assert.AreEqual(0, context.SentMessages.Length);
        Assert.AreEqual(0, context.PublishedMessages.Length);
    }
    public async Task Handle(RebookingWasProposed message, IMessageHandlerContext context)
    {
        logger.Info("Received RebookingWasProposed event");
        Data.IsRebookingProposed = true;
        Data.BookingReferenceId  = message.BookingReferenceId;

        if (Data.CanCompleteSaga())
        {
            logger.Info("Saga is now complete");
            MarkAsComplete();
            return;
        }

        await context.SendLocal(new NotifyCustomerAboutProposedRebooking(
                                    message.BookingReferenceId,
                                    message.ReasonForRebooking)).ConfigureAwait(false);

        await RequestTimeout(context, TimeSpan.FromSeconds(15),
                             new CancellationGracePeriodElapsed()).ConfigureAwait(false);
    }