Ejemplo n.º 1
0
        public async Task TaskFactory_Should_Return_TaskFactory_Compatible_With_Proxy_Thread_ActorFactory_Context()
        {
            //arrange
            await _Interface.DoAsync();

            //act
            var    res      = _ActorContext.GetTaskFactory(_Proxified);
            Thread tfthread = await res.StartNew(() => Thread.CurrentThread);

            //assert
            tfthread.Should().NotBeNull();
            tfthread.Should().Be(_Proxified.CallingThread);
        }
Ejemplo n.º 2
0
        public async Task BuildAsync_Should_Call_Constructor_On_Actor_Thread()
        {
            var              current = Thread.CurrentThread;
            DummyClass       target  = null;
            IDummyInterface2 intface = await _Factory.BuildAsync <IDummyInterface2>(() => { target = new DummyClass(); return(target); });

            await intface.DoAsync();

            target.Done.Should().BeTrue();
            target.CallingConstructorThread.Should().NotBe(current);
            target.CallingConstructorThread.Should().Be(target.CallingThread);
        }
        public async Task DisposeAsync_On_Factory_Should_Kill_Thread()
        {
            //arrange
            var target1 = new DummyClass();

            _Actor1 = _Factory.Build <IDummyInterface2>(target1);

            //act
            await _Actor1.DoAsync();

            //assert
            await _Factory.DisposeAsync();

            Thread.Yield();
            target1.CallingThread.IsAlive.Should().BeFalse();
        }
        public async Task All_Actors_Should_Run_On_Same_Thread()
        {
            //arrange
            var target1 = new DummyClass();
            var target2 = new DummyClass();

            _Actor1 = _Factory.Build <IDummyInterface2>(target1);
            _Actor2 = _Factory.Build <IDummyInterface2>(target2);

            //act
            await _Actor1.DoAsync();

            await _Actor2.DoAsync();

            //assert
            target1.CallingThread.Should().Be(target2.CallingThread);
        }