public async Task VerifyMockedGuidGrainThrowsNotActivatedWhenMethodNotCalled() { var clusterFixture = new ClusterFixture { OutputHelper = testOutputHelper }; await clusterFixture.Start(); using (clusterFixture) await clusterFixture.Dispatch(() => { var primaryKey = Guid.NewGuid(); clusterFixture.Mock.GuidGrain <ITestGuidGrain>(primaryKey); Assert.ThrowsAny <Exception>(() => clusterFixture.Mock.VerifyGuidGrainActivated <ITestGuidGrain>(primaryKey)); return(Task.CompletedTask); }); }
public async Task VerifyMockedGuidGrainDoesNotThrowOnVerifyActivatedWhenMethodCalled() { var clusterFixture = new ClusterFixture { OutputHelper = testOutputHelper }; await clusterFixture.Start(); using (clusterFixture) await clusterFixture.Dispatch(async() => { var primaryKey = Guid.NewGuid(); clusterFixture.Mock.GuidGrain <ITestGuidGrain>(primaryKey); var mockGrain = clusterFixture.Mock.Mock.Object.GetGrain <ITestGuidGrain>(primaryKey); await mockGrain.Foo(); clusterFixture.Mock.VerifyGuidGrainActivated <ITestGuidGrain>(primaryKey); }); }
public async Task SubscribedGrainStillSubscribedAfterDeactivation() { using (var clusterFixture = new ClusterFixture()) { await clusterFixture.Start(); 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); }); } }
public async Task SubscribeCallToGrainCallsRedisStringSet() { using (var clusterFixture = new ClusterFixture()) { await clusterFixture.Start(); await clusterFixture.Dispatch(async() => { var writeSemaphore = new SemaphoreSlim(0); clusterFixture.Redis .Setup(x => x.StringSet(It.IsAny <RedisKey>(), It.IsAny <RedisValue>(), It.IsAny <TimeSpan?>(), It.IsAny <When>(), It.IsAny <CommandFlags>())) .Callback((RedisKey key, RedisValue value, TimeSpan? timeSpan, When when, CommandFlags flags) => writeSemaphore.Release()); var grain = clusterFixture.GrainFactory.GetGrain <ITestGrain>(Guid.Empty); await grain.Subscribe(); await writeSemaphore.WaitAsync(GetDefaultBlockingToken()); }); } }