public void Component_depending_on_unregistered_context_via_type_throws_even_if_another_is_available() { Container.Register(Component.For<ClassInContextWithMissingDependency>(), Component.For<SynchronizationContext>().Named("foo").UsingFactoryMethod(k => k.Resolve<WindowsFormsSynchronizationContext>())); var instance = Container.Resolve<ClassInContextWithMissingDependency>(); var form = new DummyForm(); ExecuteInThread(() => instance.DoWork(form)); }
public void DoWorkGeneric_DifferentThreadInContext_WorksFine() { var form = new DummyForm(); var client = Container.Resolve<IClassUsingContext<DummyForm>>(); ExecuteInThread(() => Assert.AreEqual(form, client.DoWork(form))); Assert.IsNull(uncaughtException, "Expected no exception"); }
public void AddControl_DifferentThreadInContext_WorksFine() { var form = new DummyForm(); var client = Container.Resolve<ClassUsingFormInWindowsContext>(); ExecuteInThread(() => { client.DoWork(form); }); Assert.IsNull(uncaughtException, "Expected no exception"); }
public void AddControl_DifferentThread_ThrowsException() { var form = new DummyForm(); ExecuteInThread(() => form.AddControl(new Button())); Assert.IsNotNull(uncaughtException, "Expected an exception"); uncaughtException = null; var classInCtx = new ClassUsingFormInWindowsContext(); ExecuteInThread(() => classInCtx.DoWork(form)); Assert.IsNotNull(uncaughtException, "Expected an exception"); }
public void AddControl_DifferentThreadInContextUsingConfiguration_UsesAmbientContext() { var form = new DummyForm(); var client = Container.Resolve<ClassUsingFormInAmbientContext>(); ExecuteInThread(() => { using (var winCtx = new WindowsFormsSynchronizationContext()) { SynchronizationContext.SetSynchronizationContext(winCtx); client.DoWork(form); } }); Assert.IsNull(uncaughtException, "Expected no exception"); }