private void OpenScreen(ScreenConductor conductor, IScreenBase screen) { try { conductor.OpenScreen(ScreenFactory.For(screen)); } catch (ScreenLifecycleException) { } }
public void OpenScreenUseScreenLocation_WhenNoMatchingScreenIsOpen_CreatesNewScreen() { var conductor = CreateConductor(); var firstSubject = new BaseSubject { Value = "First Subject" }; var differentSubject = new BaseSubject { Value = "Different Subject" }; conductor.OpenScreen( ScreenFactory .For <MultipleInstancesScreen>(Locator) ); conductor.OpenScreen( ScreenFactory .WithSubject(firstSubject) .For <LocatableScreen>(Locator) ); conductor.OpenScreen( ScreenFactory .WithSubject(differentSubject) .For <LocatableScreen>(Locator) ); CollectionAssert.AreEqual( new[] { firstSubject, differentSubject }, GetSubjectsOfOpenScreens(conductor) ); }
public void DefaultCreationBehavior() { ScreenConductor c = CreateConductor(); c.OpenScreen(ScreenFactory.For <DefaultCreationBehaviorScreen>(Locator)); c.OpenScreen(ScreenFactory.For <DefaultCreationBehaviorScreen>(Locator)); Assert.AreEqual(2, c.Screens.Count()); }
public void SingleInstance() { ScreenConductor c = CreateConductor(); c.OpenScreen(ScreenFactory.For <SingleInstanceScreen>(Locator)); c.OpenScreen(ScreenFactory.For <SingleInstanceScreen>(Locator)); Assert.AreEqual(1, c.Screens.Count()); }
public void MultipleInstances() { ScreenConductor c = CreateConductor(); c.OpenScreen(ScreenFactory.For <MultipleInstancesScreen>(Locator)); c.OpenScreen(ScreenFactory.For <MultipleInstancesScreen>(Locator)); Assert.AreEqual(2, c.Screens.Count()); }
public void TestCreateWithDefaultServiceLocator() { TestScreen screen = ScreenFactory .For <TestScreen>() .Create(Aggregator); Assert.IsNotNull(screen); }
public void ScreenFactoriesForConcreteScree_CanBeAssignedToScreenBaseFactoryVariable() { IScreenFactory <TestScreen> concreteFactory = ScreenFactory.For <TestScreen>(); IScreenFactory <IScreenBase> factory = concreteFactory; IScreenBase screen = factory.Create(Aggregator); Assert.IsInstanceOfType(screen, typeof(TestScreen)); }
public void ShowDialogWithCertainScreenInstance_ScreenLifecycleDoesntContainDialogLifecycleAfterShowDialog() { WindowService.ShowRealWindow = false; var screen = new ScreenMock(Aggregator); DialogSerivce.ShowDialog(ScreenFactory.For(screen)); Assert.IsFalse(screen.Children.OfType <DialogLifecycle>().Any()); }
public void Create_ScreenFactoryForInstance_ReturnsThisInstance() { var expected = new InitializableScreen(Aggregator); IScreenFactory <InitializableScreen> factory = ScreenFactory.For(expected); var actual = factory.Create(Aggregator); Assert.AreEqual(expected, actual); }
public void Create_ScreenFactoryForInstance_CallsInitialize() { var expected = new InitializableScreen(Aggregator); IScreenFactory <InitializableScreen> factory = ScreenFactory.For <InitializableScreen>(Locator); var actual = factory.Create(Aggregator); Assert.IsTrue(actual.InitializeWasCalled); }
private ScreenConductor CreateScreenConductor() { ScreenConductor conductor = ScreenFactory .For(new ScreenConductor(Aggregator)) .Create(Aggregator); new ScreenLifecycleOperations(Aggregator, conductor) .Activate(); return(conductor); }
public void OpenScreen_WithBaseClassScreenFactory_DoesNotOpenScreenIfActualTypesMatch() { ScreenConductor c = CreateConductor(); c.OpenScreen(ScreenFactory.For <SingleInstanceScreen>(Locator)); IScreenFactory <IScreenBase> baseFactory = ScreenFactory .For <SingleInstanceScreen>(Locator); c.OpenScreen(baseFactory); Assert.AreEqual(1, c.Screens.Count()); }
public void TestServiceLocatorIsUsed() { var locatorMock = new Mock <IServiceLocator>(); locatorMock .Setup(x => x.GetInstance <TestScreen>()) .Returns(new TestScreen("Test")); TestScreen screen = ScreenFactory .For <TestScreen>(locatorMock.Object) .Create(Aggregator); Assert.AreEqual("Test", screen.Dependency); }
public void OpenScreen_WhenScreenIsNotAlreadyOpen_PublishesScreenOpenedEvent() { var conductor = CreateScreenConductor(); var newScreen = new SingleInstanceScreen(); var eventArgs = ExpectScreenOpenedEvent(() => { conductor.OpenScreen(ScreenFactory.For(newScreen)); }); Assert.IsNotNull(eventArgs); Assert.AreEqual(conductor, eventArgs.Conductor); Assert.AreEqual(newScreen, eventArgs.Screen); Assert.IsFalse(eventArgs.WasAlreadyOpen); }
public void GetAssociatedWindow_ReturnsWindow() { WindowService.ShowRealWindow = false; WindowView window = new WindowView(false); ScreenMock screen = new ScreenMock(Aggregator); DialogSerivce.Show( window, ScreenFactory.For(screen), modal: false ); Assert.AreEqual(window, DialogSerivce.GetAssociatedWindow(screen)); }
public void Show_AttachesAppropriateChildren() { WindowService.ShowRealWindow = false; var screen = new ScreenMock(Aggregator); DialogSerivce.Show( new WindowView(false), ScreenFactory.For(screen), modal: false ); Assert.IsTrue(screen.Children.OfType <WindowLifecycle>().Any()); Assert.IsTrue(screen.Children.OfType <ScreenCloseHandler>().Any()); Assert.IsFalse(screen.Children.OfType <DialogLifecycle>().Any()); }
public void OpenScreen_WhenScrenIsAlreadyOpen_DoesNotAddScreenCloseHandler() { var conductor = CreateScreenConductor(); var alreadyOpenedScreen = new SingleInstanceScreen(); conductor.OpenScreen(ScreenFactory.For(alreadyOpenedScreen)); conductor.OpenScreen(ScreenFactory.For(alreadyOpenedScreen)); Assert.AreEqual( 1, alreadyOpenedScreen .Children .OfType <ScreenCloseHandler>() .Count() ); }
public void CloseView_CallsRequestClose() { bool isCloseAllowed = false; TestScreen screen = new TestScreen(Aggregator); screen.Lifecycle.RegisterHandler( ScreenEvents.RequestClose, args => args.IsCloseAllowed = isCloseAllowed ); Conductor.OpenScreen(ScreenFactory.For(screen)); object view = Adapter .Views .Cast <Object>() .Single(); Assert.IsFalse(Adapter.CloseView(view)); isCloseAllowed = true; Assert.IsTrue(Adapter.CloseView(view)); }
private void ShowDialog(IScreenBase screen) { DialogSerivce.ShowDialog(ScreenFactory.For(screen)); }
public void AddScreen_SetsParent() { TestScreen s = Collection.AddScreen(ScreenFactory.For <TestScreen>(Locator)); Assert.AreEqual(Parent, s.Parent); }
public ShellScreen(EventAggregator aggregator) : base(aggregator) { WorkScreens = Children.AddScreen(ScreenFactory.For <ScreenConductor>()); }