Exemplo n.º 1
0
        public async Task CreateAsync_CallsConstructor()
        {
            var activator = new DefaultActorActivator();

            var host  = ActorHost.CreateForTest <TestActor>();
            var state = await activator.CreateAsync(host);

            Assert.IsType <TestActor>(state.Actor);
        }
Exemplo n.º 2
0
        public async Task DeleteAsync_NotDisposable()
        {
            var activator = new DefaultActorActivator();

            var host  = ActorHost.CreateForTest <TestActor>();
            var actor = new TestActor(host);
            var state = new ActorActivatorState(actor);

            await activator.DeleteAsync(state); // does not throw
        }
Exemplo n.º 3
0
        public async Task DeleteAsync_AsyncDisposable()
        {
            var activator = new DefaultActorActivator();

            var host  = ActorHost.CreateForTest <AsyncDisposableActor>();
            var actor = new AsyncDisposableActor(host);
            var state = new ActorActivatorState(actor);

            await activator.DeleteAsync(state);

            Assert.True(actor.IsDisposed);
        }
        public async Task CreateAsync_CanActivateWithDI()
        {
            var activator = CreateActivator(typeof(TestActor));

            var host  = ActorHost.CreateForTest <TestActor>();
            var state = await activator.CreateAsync(host);

            var actor = Assert.IsType <TestActor>(state.Actor);

            Assert.NotNull(actor.SingletonService);
            Assert.NotNull(actor.ScopedService);
        }
        public async Task DeleteAsync_AsyncDisposable()
        {
            var activator = CreateActivator(typeof(AsyncDisposableActor));

            var host  = ActorHost.CreateForTest <AsyncDisposableActor>();
            var state = await activator.CreateAsync(host);

            var actor = Assert.IsType <AsyncDisposableActor>(state.Actor);

            await activator.DeleteAsync(state);

            Assert.True(actor.IsDisposed);
        }
Exemplo n.º 6
0
        public async Task CreateAsync_CustomJsonOptions()
        {
            var jsonOptions = new System.Text.Json.JsonSerializerOptions {
                PropertyNameCaseInsensitive = false
            };
            var activator = CreateActivator(typeof(TestActor));

            var host = ActorHost.CreateForTest <TestActor>(new ActorTestOptions {
                JsonSerializerOptions = jsonOptions
            });
            var state = await activator.CreateAsync(host);

            Assert.Same(jsonOptions, state.Actor.Host.JsonSerializerOptions);
        }
        public async Task DeleteAsync_DisposesScope()
        {
            var activator = CreateActivator(typeof(TestActor));

            var host  = ActorHost.CreateForTest <TestActor>();
            var state = await activator.CreateAsync(host);

            var actor = Assert.IsType <TestActor>(state.Actor);

            Assert.False(actor.ScopedService.IsDisposed);

            await activator.DeleteAsync(state);

            Assert.True(actor.ScopedService.IsDisposed);
        }
        public async Task CreateAsync_CreatesNewScope()
        {
            var activator = CreateActivator(typeof(TestActor));

            var host1  = ActorHost.CreateForTest <TestActor>();
            var state1 = await activator.CreateAsync(host1);

            var actor1 = Assert.IsType <TestActor>(state1.Actor);

            var host2  = ActorHost.CreateForTest <TestActor>();
            var state2 = await activator.CreateAsync(host2);

            var actor2 = Assert.IsType <TestActor>(state2.Actor);

            Assert.Same(actor1.SingletonService, actor2.SingletonService);
            Assert.NotSame(actor1.ScopedService, actor2.ScopedService);
        }