public void When_application_context_is_started_it_will_initialized_all_the_module_loader() { MockRepository mocks = new MockRepository(); IModuleLoader mockLoader1 = mocks.DynamicMock <IModuleLoader>(); IModuleLoader mockLoader2 = mocks.DynamicMock <IModuleLoader>(); IModuleLoader mockLoader3 = mocks.DynamicMock <IModuleLoader>(); IApplicationShell stubShell = mocks.Stub <IApplicationShell>(); DefaultApplicationContext context = mocks.PartialMock <DefaultApplicationContext>( stubShell, mocks.DynamicMock <ILayoutRegistry>(), new IModuleLoader[] { mockLoader1, mockLoader2, mockLoader3 }); //we may have order dependnecies, let us verify //that it does this in order using (mocks.Record()) using (mocks.Ordered()) { mockLoader1.Initialize(context, stubShell); mockLoader2.Initialize(context, stubShell); mockLoader3.Initialize(context, stubShell); } using (mocks.Playback()) { context.Start(); } }
public void WillInitializeAllModuleLoadersOnStart() { MockRepository mocks = new MockRepository(); IModuleLoader mockLoader1 = mocks.DynamicMock <IModuleLoader>(); IModuleLoader mockLoader2 = mocks.DynamicMock <IModuleLoader>(); IModuleLoader mockLoader3 = mocks.DynamicMock <IModuleLoader>(); IShellView stubShell = mocks.Stub <IShellView>(); DefaultApplicationContext context = mocks.PartialMock <DefaultApplicationContext>( stubShell, new IModuleLoader[] { mockLoader1, mockLoader2, mockLoader3 }); using (mocks.Record()) { //we may have order dependnecies, let us verify //that it does this in order using (mocks.Ordered()) { mockLoader1.Initialize(context, stubShell); mockLoader2.Initialize(context, stubShell); mockLoader3.Initialize(context, stubShell); } //force context to ignore these calls Expect.Call(context.GetShellAsForm()).Return(null).Repeat.Once(); Expect.Call(delegate { context.RunForm(null); }).Repeat.Once(); } using (mocks.Playback()) { context.Start(); } }
public void WillCastShellToFormIfInheritFromForm() { DefaultApplicationContext context = new DefaultApplicationContext(new DemoForm(), new IModuleLoader[] { }); Form form = context.GetShellAsForm(); Assert.IsNotNull(form); }
public void CallingStartWillShowTheForm() { DemoForm shell = new DemoForm(); DefaultApplicationContext context = new DefaultApplicationContext(shell, new IModuleLoader[] { }); context.Start(); Assert.IsTrue(shell.WasShown); }
public void CallingStartWillShowTheForm() { DemoForm shell = new DemoForm(); DefaultApplicationContext context = new DefaultApplicationContext(shell, new IModuleLoader[] { }); context.Start(); Assert.IsTrue(shell.WasShown); }
public void WillThrowIfShellIsNotForm() { IShellView stubShell = MockRepository.GenerateStub<IShellView>(); DefaultApplicationContext context = new DefaultApplicationContext(stubShell, new IModuleLoader[] { }); try { context.GetShellAsForm(); Assert.Fail("Should have thrown"); } catch (Exception ex) { StringAssert.Like(ex.Message, @"The IShellView implementation IShellViewProxy[\w\d]+ should be derived from System\.Windows\.Forms\.Form"); } }
public void WillThrowIfShellIsNotForm() { IShellView stubShell = MockRepository.GenerateStub <IShellView>(); DefaultApplicationContext context = new DefaultApplicationContext(stubShell, new IModuleLoader[] { }); try { context.GetShellAsForm(); Assert.Fail("Should have thrown"); } catch (Exception ex) { StringAssert.Like(ex.Message, @"The IShellView implementation IShellViewProxy[\w\d]+ should be derived from System\.Windows\.Forms\.Form"); } }
public void WillRaiseReadableErrorIfShellIsNull() { DefaultApplicationContext context = new DefaultApplicationContext(null, new IModuleLoader[] { }); context.Start(); }
public void WillRaiseReadableErrorIfShellIsNull() { DefaultApplicationContext context = new DefaultApplicationContext(null, new IModuleLoader[] { }); context.Start(); }
public void WillCastShellToFormIfInheritFromForm() { DefaultApplicationContext context = new DefaultApplicationContext(new DemoForm(), new IModuleLoader[] { }); Form form = context.GetShellAsForm(); Assert.IsNotNull(form); }