Example #1
0
        public async Task SubscribedGrainStillSubscribedAfterDeactivation()
        {
            using (var clusterFixture = new ClusterFixture())
                await clusterFixture.Dispatch(async() =>
                {
                    var grain = clusterFixture.GrainFactory.GetGrain <ITestGrain>(Guid.Empty);
                    await grain.Subscribe();
                    await grain.Deactivate();

                    await clusterFixture.PublishToStream(StreamProviderName, Guid.Empty, DefaultStreamNamespace, "some item");

                    await TestGrain.Semaphore.WaitAsync(GetDefaultBlockingToken());
                    Assert.True(TestGrain.DidResumeSubscription);
                });
        }
Example #2
0
        private async Task <(Guid StreamId, string StreamNamespace, Task <List <dynamic> > Awaiter)> CreateProducerConsumerStreamAwaiter(ClusterFixture clusterFixture, int messageCount)
        {
            var streamId                  = Guid.NewGuid();
            var streamNamespace           = Guid.NewGuid().ToString();
            var streamSubscriptionAwaiter = await clusterFixture.SubscribeAndGetTaskAwaiter <string>(StreamProviderName, streamId, streamNamespace, messageCount);

            var publishTask = Task.Factory.StartNew(async() =>
            {
                for (var i = 0; i < messageCount; i++)
                {
                    await clusterFixture.PublishToStream(StreamProviderName, streamId, streamNamespace, $"test:{streamId}-{streamNamespace} message:{i}");
                }
            });

            return(streamId, streamNamespace, streamSubscriptionAwaiter);
        }