public SynchronizationContextFactoryTest() { _UIMessageLoop = new WPFThreadingHelper(); _UIMessageLoop.Start().Wait(); _Factory = _UIMessageLoop.Dispatcher.Invoke(() => new SynchronizationContextFactory()); }
public async Task TaskFactory_Should_Return_TaskFactory_Compatible_With_Proxy_Thread_SynchronizationContextFactory_Context() { //arrange var UIMessageLoop = new WPFThreadingHelper(); UIMessageLoop.Start().Wait(); var scf = UIMessageLoop.Dispatcher.Invoke(() => new SynchronizationContextFactory()); _Proxified = new DummyClass(); _Interface = scf.Build<IDummyInterface2>(_Proxified); //act var res = _ActorContext.GetTaskFactory(_Proxified); Thread tfthread = await res.StartNew(() => Thread.CurrentThread); //assert tfthread.Should().Be(UIMessageLoop.UIThread); UIMessageLoop.Stop(); }
public void GetTaskScheduler_Should_Return_SynchronizationContext_Compatible_With_Proxy_Thread_SynchronizationContextFactory_Context() { //arrange var UIMessageLoop = new WPFThreadingHelper(); UIMessageLoop.Start().Wait(); var scf = UIMessageLoop.Dispatcher.Invoke(() => new SynchronizationContextFactory()); _Proxified = new DummyClass(); _Interface = scf.Build<IDummyInterface2>(_Proxified); //act var res = _ActorContext.GetTaskScheduler(_Proxified); var uisc = UIMessageLoop.Dispatcher.Invoke(()=> SynchronizationContext.Current); //assert res.Should().NotBeNull(); res.Should().BeOfType<SynchronizationContextTaskScheduler>(); var ressync = res as SynchronizationContextTaskScheduler; ressync.SynchronizationContext.Should().BeOfType(uisc.GetType()); UIMessageLoop.Stop(); }