Esempio n. 1
0
        public async Task DisconnectsClusterClient()
        {
            // arrange
            var id     = Guid.NewGuid();
            var config = new ConfigurationBuilder()
                         .AddInMemoryCollection(new Dictionary <string, string>
            {
                { "Orleans:Ports:Gateway:Start", "30000" },
                { "Orleans:Ports:Gateway:End", "30000" },
                { "Orleans:ClusterId", "dev" },
                { "Orleans:ServiceId", "dev" },
                { "Orleans:Providers:Clustering:Provider", "Localhost" }
            })
                         .Build();

            // act
            var service = new ClusterClientHostedService(config, loggerProvider);
            await service.StartAsync(default(CancellationToken));

            await service.StopAsync(default(CancellationToken));

            // assert
            Assert.False(service.ClusterClient.IsInitialized);
            await Assert.ThrowsAsync <ObjectDisposedException>(async() =>
            {
                await service.ClusterClient.GetGrain <ITestGrain>(id).GetKeyAsync();
            });
        }
Esempio n. 2
0
        public void BuildsClusterClient()
        {
            // arrange
            var id     = Guid.NewGuid();
            var config = new ConfigurationBuilder()
                         .AddInMemoryCollection(new Dictionary <string, string>
            {
                { "Orleans:Ports:Gateway:Start", "30000" },
                { "Orleans:Ports:Gateway:End", "30000" },
                { "Orleans:ClusterId", "dev" },
                { "Orleans:ServiceId", "dev" },
                { "Orleans:Providers:Clustering:Provider", "Localhost" }
            })
                         .Build();

            // act
            var service = new ClusterClientHostedService(config, loggerProvider);

            // assert
            Assert.NotNull(service.ClusterClient);
            Assert.False(service.ClusterClient.IsInitialized);
        }
Esempio n. 3
0
        public async Task FailsToConnectClusterClient()
        {
            // arrange
            var id     = Guid.NewGuid();
            var config = new ConfigurationBuilder()
                         .AddInMemoryCollection(new Dictionary <string, string>
            {
                { "Orleans:Ports:Gateway:Start", "12345" },
                { "Orleans:Ports:Gateway:End", "12345" },
                { "Orleans:ClusterId", "dev" },
                { "Orleans:ServiceId", "dev" },
                { "Orleans:Providers:Clustering:Provider", "Localhost" }
            })
                         .Build();

            // act and assert
            var service = new ClusterClientHostedService(config, loggerProvider);
            await Assert.ThrowsAsync <OrleansMessageRejectionException>(async() =>
            {
                await service.StartAsync(default(CancellationToken));
            });
        }