public async Task Test(bool TaskPool) { IActorFactory fact = new ActorFactory(t=>t.Priority=_Priority); var One = new PingPonger("Bjorg"); IPingPonger Actor1 = fact.Build<IPingPonger>(One); var Two = new PingPonger("Lendl"); var fact2 = TaskPool ? new TaskPoolActorFactory() : fact; IPingPonger Actor2 = fact2.Build<IPingPonger>(Two); One.Ponger = Actor2; Two.Ponger = Actor1; var watch = new Stopwatch(); watch.Start(); await Actor1.Ping(); Thread.Sleep(10000); var lifeCyle = Actor2 as IActorCompleteLifeCycle; Task Task2 = (lifeCyle == null) ? TaskBuilder.Completed : lifeCyle.Abort(); await Task.WhenAll(((IActorCompleteLifeCycle)(Actor1)).Abort(), Task2); watch.Stop(); Console.WriteLine("Total Ping:{0} Total Time: {1}", One.Count, watch.Elapsed); Console.WriteLine(One.Count); Console.WriteLine(Two.Count); }
public ActorContextTest() { _ActorContext = new ActorContext(); var factory = new ActorFactory(); _Proxified = new DummyClass(); _Interface = factory.Build<IDummyInterface2>(_Proxified); }
public async Task Test(bool TaskPool) { IActorFactory fact = new ActorFactory(t => t.Priority = _Priority); var One = new PingPonger("Bjorg"); IPingPonger Actor1 = fact.Build <IPingPonger>(One); var Two = new PingPonger("Lendl"); var fact2 = TaskPool ? new TaskPoolActorFactory() : fact; IPingPonger Actor2 = fact2.Build <IPingPonger>(Two); One.Ponger = Actor2; Two.Ponger = Actor1; var watch = new Stopwatch(); watch.Start(); await Actor1.Ping(); Thread.Sleep(10000); var lifeCyle = Actor2 as IActorCompleteLifeCycle; Task Task2 = (lifeCyle == null) ? TaskBuilder.Completed : lifeCyle.Abort(); await Task.WhenAll(((IActorCompleteLifeCycle)(Actor1)).Abort(), Task2); watch.Stop(); Console.WriteLine("Total Ping:{0} Total Time: {1}", One.Count, watch.Elapsed); Console.WriteLine(One.Count); Console.WriteLine(Two.Count); }
public ActorContextTest() { _ActorContext = new ActorContext(); var factory = new ActorFactory(); _Proxified = new DummyClass(); _Interface = factory.Build <IDummyInterface2>(_Proxified); }
public void Build_Should_Throw_Exception_IsSamePOCO_HasBeenUsedWithOtherFactory() { var target = new DummyClass(); var Factory = new ActorFactory(); var intface = Factory.Build <IDummyInterface2>(target); Action Do = () => _Factory.Build <IDummyInterface2>(target); Do.ShouldThrow <ArgumentException>().And.Message.Should().Contain("Standard"); }
public async Task Method_Should_Run_On_Separated_Thread() { var current = Thread.CurrentThread; var target = new DummyClass(); var intface = _Factory.Build <IDummyInterface2>(target); await intface.DoAsync(); target.Done.Should().BeTrue(); target.CallingThread.Should().NotBeNull(); target.CallingThread.Should().NotBe(current); }
public void Build_Should_Throw_Exception_IsSamePOCO_HasBeenUsedWithOtherFactory() { var target = new DummyClass(); var Factory = new ActorFactory(); var intface = Factory.Build<IDummyInterface2>(target); Action Do = () => _Factory.Build<IDummyInterface2>(target); Do.ShouldThrow<ArgumentException>().And.Message.Should().Contain("Standard"); }