public async Task Actor_IActorLifeCycle_Abort_Should_Cancel_Enqueued_Task() { //arrange var dispclass = new DisposableClass(); var intface = _Factory.Build<IDummyInterface1>(dispclass); Task Taskrunning = intface.DoAsync(), Takenqueued = intface.DoAsync(); Thread.Sleep(100); //act IActorCompleteLifeCycle disp = intface as IActorCompleteLifeCycle; await disp.Abort(); //assert TaskCanceledException error = null; try { await Takenqueued; } catch (TaskCanceledException e) { error = e; } //assert error.Should().NotBeNull(); Takenqueued.IsCanceled.Should().BeTrue(); }
public async Task Actor_Should_Return_Cancelled_Task_On_Any_Method_AfterCalling_IActorLifeCycle_Abort() { //arrange var dispclass = new DisposableClass(); var intface = _Factory.Build<IDummyInterface1>(dispclass); //act var task = intface.DoAsync(); var disp = intface as IActorCompleteLifeCycle; await disp.Abort(); TaskCanceledException error = null; Task canc = null; try { canc = intface.DoAsync(); await canc; } catch (TaskCanceledException e) { error = e; } //assert error.Should().NotBeNull(); task.IsCompleted.Should().BeTrue(); canc.IsCanceled.Should().BeTrue(); }
public async Task Actor_IActorLifeCycle_Abort_Should_Not_Cancel_RunningTask() { //arrange var taskCompletionSource = new TaskCompletionSource<object>(); var progress = new Progress<int>(i => taskCompletionSource.TrySetResult(null)); var dispclass = new DisposableClass(); var intface = _Factory.Build<IDummyInterface1>(dispclass); IActorCompleteLifeCycle disp = intface as IActorCompleteLifeCycle; //act var Taskrunning = intface.DoAsync(progress); await taskCompletionSource.Task; await disp.Abort(); await Taskrunning; Thread.Sleep(100); //assert Taskrunning.IsCompleted.Should().BeTrue(); }
public async Task Actor_IActorLifeCycle_Abort_Should_Call_Proxified_Class_On_IAsyncDisposable() { //arrange var dispclass = new DisposableClass(); var intface = _Factory.Build<IDummyInterface1>(dispclass); //act IActorCompleteLifeCycle disp = intface as IActorCompleteLifeCycle; await disp.Abort(); //assert dispclass.IsDisposed.Should().BeTrue(); }
public async Task Actor_IActorLifeCycle_Stop_Should_Not_Cancel_Enqueued_Task() { //arrange var dispclass = new DisposableClass(); var intface = _Factory.Build<IDummyInterface1>(dispclass); Task Taskrunning = intface.DoAsync(), Takenqueued = intface.DoAsync(); Thread.Sleep(100); //act IActorCompleteLifeCycle disp = intface as IActorCompleteLifeCycle; await disp.Stop(); await Takenqueued; //assert Takenqueued.IsCompleted.Should().BeTrue(); }
public async Task Stop_Should_Call_Actor_IAsyncDisposable_DisposeAsync_Thread() { //arrange var target1 = new DisposableClass(); var intface1 = _Factory.Build<IDummyInterface1>(target1); //act await intface1.DoAsync(); //assert await _Factory.Stop(); target1.IsDisposed.Should().BeTrue(); }
public async Task Actor_IActorLifeCycle_Stop_Should_Call_Proxified_Class_On_IAsyncDisposable() { //arrange var dispclass = new DisposableClass(); var intface = _TaskPoolActorFactory.Build<IDummyInterface1>(dispclass); //act var disp = (IActorLifeCycle) intface; await disp.Stop(); //assert dispclass.IsDisposed.Should().BeTrue(); }