Ejemplo n.º 1
0
        public async Task TestTearDownStreamBroken()
        {
            var source = new MultiStreamProvider <int>(_provider, 2);

            var query = await source.Select(x => x, GrainClient.GrainFactory);

            var queryOutputStreams = await query.GetStreamIdentities();

            var resultConsumer = new TestTransactionalStreamConsumerAggregate <int>(_provider);
            await resultConsumer.SetInput(queryOutputStreams);

            Assert.AreEqual(2, queryOutputStreams.Count);
            Assert.AreEqual(0, resultConsumer.Items.Count);

            Assert.IsFalse(await resultConsumer.AllConsumersTearDownCalled());

            await query.TearDown();

            await resultConsumer.TearDown();

            Assert.IsTrue(await resultConsumer.AllConsumersTearDownCalled());

            await source.SendItems(new List <int>() { 2, 3 });

            Assert.AreEqual(0, resultConsumer.Items.Count);
            Assert.IsTrue(await resultConsumer.AllConsumersTearDownCalled());
        }
Ejemplo n.º 2
0
        private async Task TestMultiLevelDataPass <TIn, TOut>(
            Func <MultiStreamProvider <TIn>, IStreamProcessorAggregateFactory, Task <IStreamProcessorChain <TOut> > >
            createStreamProcessingChainFunc, List <List <TIn> > inputChunks, List <List <TOut> > outputChunks,
            Action <List <TOut>, List <TOut> > resultAssertion)
        {
            if (inputChunks.Count != outputChunks.Count)
            {
                throw new ArgumentException();
            }

            var source = new MultiStreamProvider <TIn>(_provider, 2);

            var query = await createStreamProcessingChainFunc(source, new DefaultStreamProcessorAggregateFactory(GrainFactory));

            var queryOutputStreams = await query.GetStreamIdentities();

            var resultConsumer = new TestTransactionalStreamConsumerAggregate <TOut>(_provider);
            await resultConsumer.SetInput(queryOutputStreams);

            Assert.AreEqual(2, queryOutputStreams.Count);
            Assert.AreEqual(0, resultConsumer.Items.Count);

            for (int i = 0; i < inputChunks.Count; i++)
            {
                var input          = inputChunks[i];
                var expectedOutput = outputChunks[i];
                await source.SendItems(input);

                resultAssertion(expectedOutput, resultConsumer.Items);
                resultConsumer.Items.Clear();
            }

            await query.TearDown();

            await resultConsumer.TearDown();
        }