public GrainTests(ClusterFixture fixture)
        {
            // extract the TestCluster instance here and save it...
            _cluster = fixture?.Cluster ?? throw new ArgumentNullException(nameof(fixture));

            // create a single grain to test if you want here, or alternately create a grain in the test itself
            _calculatorGrain = _cluster.GrainFactory.GetGrain <ICalculatorGrain>(Guid.NewGuid());
        }
Exemple #2
0
        private static async Task StaySubscribed(ICalculatorGrain grain, ICalculatorObserver observer, CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                try
                {
                    await Task.Delay(TimeSpan.FromSeconds(5), token);

                    await grain.Subscribe(observer);
                }
                catch (Exception exception)
                {
                    Console.WriteLine($"Exception while trying to subscribe for updates: {exception}");
                }
            }
        }