Esempio n. 1
0
        public async Task <bool> SendWithReceiverDown()
        {
            cleanDatabase();

            // Shutting it down
            theReceiver.Dispose();
            theReceiver = null;


            var item = new ItemCreated
            {
                Name = "Shoe",
                Id   = Guid.NewGuid()
            };

            await send(c => c.Send(item));

            var outgoing = loadAllOutgoingEnvelopes(theSender).SingleOrDefault();

            StoryTellerAssert.Fail(outgoing == null, "No outgoing envelopes are persisted");
            StoryTellerAssert.Fail(outgoing.MessageType != typeof(ItemCreated).ToMessageTypeName(),
                                   $"Envelope message type expected {typeof(ItemCreated).ToMessageTypeName()}, but was {outgoing.MessageType}");

            return(true);
        }
Esempio n. 2
0
        public async Task <bool> CanSendItemDurably()
        {
            cleanDatabase();


            var item = new ItemCreated
            {
                Name = "Shoe",
                Id   = Guid.NewGuid()
            };

            var waiter = theTracker.WaitFor <ItemCreated>();

            await send(c => c.Send(item));

            await waiter;

            await Task.Delay(500.Milliseconds());


            await assertReceivedItemMatchesSent(item);

            await assertIncomingEnvelopesIsZero();


            var senderCounts = await assertNoPersistedOutgoingEnvelopes();

            StoryTellerAssert.Fail(senderCounts.Outgoing > 0, "There are still persisted, outgoing messages");

            return(true);
        }
Esempio n. 3
0
        public async Task <bool> CanSendItemDurably()
        {
            cleanDatabase();


            var item = new ItemCreated
            {
                Name = "Shoe",
                Id   = Guid.NewGuid()
            };

            await theSender.TrackActivity().AlsoTrack(theReceiver).SendMessageAndWait(item);

            await Task.Delay(500.Milliseconds());


            await assertReceivedItemMatchesSent(item);

            await assertIncomingEnvelopesIsZero();


            var senderCounts = await assertNoPersistedOutgoingEnvelopes();

            StoryTellerAssert.Fail(senderCounts.Outgoing > 0, "There are still persisted, outgoing messages");

            return(true);
        }
Esempio n. 4
0
        private async Task assertReceivedItemMatchesSent(ItemCreated item)
        {
            var received = loadItem(theReceiver, item.Id);

            if (received == null)
            {
                await Task.Delay(500.Milliseconds());
            }
            received = loadItem(theReceiver, item.Id);

            StoryTellerAssert.Fail(received.Name != item.Name, "The persisted item does not match");
        }
Esempio n. 5
0
        public async Task <bool> CanScheduleJobDurably()
        {
            cleanDatabase();

            var item = new ItemCreated
            {
                Name = "Shoe",
                Id   = Guid.NewGuid()
            };

            await send(async c => { await c.Schedule(item, 1.Hours()); });

            var persistor = theSender.Get <IEnvelopePersistor>();
            var counts    = await persistor.GetPersistedCounts();

            StoryTellerAssert.Fail(counts.Scheduled != 1, $"counts.Scheduled = {counts.Scheduled}, should be 0");


            return(true);
        }