private void RunStatePersistenceTest2(string instanceName)
        {
            Debug.WriteLine($"Start of {nameof(RunStatePersistenceTest2)}");

            TableStoragePersistenceProvider prov = new TableStoragePersistenceProvider();

            prov.InitializeAsync(instanceName, new Dictionary <string, object>()
            {
                { "StorageConnectionString", storageConnStr }
            }, purgeOnStart: false).Wait();

            var         cfg       = DotNetActorsTests.GetLocaSysConfig();
            ActorSystem sysLocal  = new ActorSystem($"{nameof(TblStatePersistenceTest)}/local", cfg);
            ActorSystem sysRemote = new ActorSystem($"{nameof(TblStatePersistenceTest)}/remote", DotNetActorsTests.GetRemoteSysConfig(), persistenceProvider: prov);

            CancellationTokenSource src = new CancellationTokenSource();

            var task = Task.Run(() =>
            {
                sysRemote.Start(src.Token);

                prov.Purge().Wait();
            });

            ActorReference actorRef1 = sysLocal.CreateActor <CounterActor>(1);

            var response = actorRef1.Ask <long>((long)1).Result;

            Assert.IsTrue(response == 50);

            src.Cancel();

            Debug.WriteLine($"End of {nameof(RunStatePersistenceTest2)}");
        }
示例#2
0
        private void RunStatePersistenceTest1(string instanceName)
        {
            Debug.WriteLine($"Start of {nameof(RunStatePersistenceTest1)}");

            BlobStoragePersistenceProvider prov = new BlobStoragePersistenceProvider();
            //prov.InitializeAsync(instanceName, new Dictionary<string, object>() { { "StorageConnectionString", storageConnStr } }, purgeOnStart: false).Wait();

            var         cfg      = DotNetActorsTests.GetLocaSysConfig();
            ActorSystem sysLocal = new ActorSystem($"{nameof(BlobStatePersistenceTest)}/local", cfg);

            // TODO: Passing persistence provider null until connection string is not fixed
            ActorSystem sysRemote = new ActorSystem($"{nameof(BlobStatePersistenceTest)}/remote", DotNetActorsTests.GetRemoteSysConfig(), null);

            CancellationTokenSource src = new CancellationTokenSource();

            var task = Task.Run(() =>
            {
                sysRemote.Start(src.Token);
            });

            ActorReference actorRef1 = sysLocal.CreateActor <CounterActor>(1);

            var response = actorRef1.Ask <long>((long)42).Result;

            Assert.IsTrue(response == 42);

            response = actorRef1.Ask <long>((long)7).Result;

            Assert.IsTrue(response == 49);

            src.Cancel();

            Debug.WriteLine($"End of {nameof(RunStatePersistenceTest1)}");
        }