public void UnsupportedReplaceFactoryTest() { // - Arrange var registry = new ScreenRegistry(); var screenStack = new ScreenStack(); var specs = new NavigatorSpecification(false, false, false); var screenA = new Mock <Screen>().Object; var screenB = new ScreenStub(); var screenBResolver = new Mock <IScreenResolver>().Object; registry.Register(typeof(ScreenStub), screenBResolver); screenStack.Push(screenB, screenA, screenA); var cf = new DefaultCommandsFactory(registry); // - Act var commands = cf.ReplaceScreen(screenStack, specs, screenB); // - Assert Assert.AreEqual(2, commands.Count); Assert.IsInstanceOf <BackNavCommand>( commands.ElementAtOrDefault(0)); Assert.IsInstanceOf <ForwardNavCommand>( commands.ElementAtOrDefault(1)); }
public ICollection <INavCommand> BackToScreen( IEnumerable <Screen> screens, NavigatorSpecification spec, Class <Screen> screenClass) { var commands = new List <INavCommand>(); if (spec.BackToScreenSupported) { commands.Add(new BackToScreenNavCommand(screenClass)); } else { var position = screens .Select(e => e.GetType()) .PositionOf(screenClass.Type); for (var i = 0; i < position; i++) { commands.Add(new BackNavCommand()); } } return(commands); }
public void DefaultSpecificationTest() { // - Act var specification = new NavigatorSpecification(); // - Assert Assert.IsFalse(specification.ReplaceScreenSupported); Assert.IsFalse(specification.BackToRootSupported); Assert.IsFalse(specification.BackToScreenSupported); }
public void SetSpecificationTest() { // - Act var specification = new NavigatorSpecification(true, true, true); // - Assert Assert.IsTrue(specification.ReplaceScreenSupported); Assert.IsTrue(specification.BackToRootSupported); Assert.IsTrue(specification.BackToScreenSupported); }
public void UnsupportedBackToScreenFactoryTest() { // - Arrange var registry = new ScreenRegistry(); var screenStack = new ScreenStack(); var specs = new NavigatorSpecification(false, false, false); var screenA = new Mock <Screen>().Object; var screenB = new ScreenStub(); screenStack.Push(screenA, screenB, screenA, screenA); var cf = new DefaultCommandsFactory(registry); // - Act var commands = cf.BackToScreen(screenStack, specs, typeof(ScreenStub)); // - Assert Assert.AreEqual(2, commands.Count); CollectionAssert.AllItemsAreInstancesOfType(commands, typeof(BackNavCommand)); }
public ICollection <INavCommand> ReplaceScreen( IEnumerable <Screen> screens, NavigatorSpecification spec, Screen screen) { var entry = _registry.Resolve(screen); var commands = new List <INavCommand>(); if (spec.ReplaceScreenSupported) { commands.Add(new ReplaceScreenNavCommand(screen, entry.Resolver)); } else { commands.Add(new BackNavCommand()); commands.Add(new ForwardNavCommand(screen, entry.Resolver)); } return(commands); }
public ICollection <INavCommand> BackToRoot( IEnumerable <Screen> screens, NavigatorSpecification spec) { var commands = new List <INavCommand>(); if (spec.BackToRootSupported) { commands.Add(new BackToRootNavCommand()); } else { var count = screens.Count(); for (var i = 1; i < count; i++) { commands.Add(new BackNavCommand()); } } return(commands); }
public void GetNavigatorSpecs() { // - Arrange var navigatorSpecs = new NavigatorSpecification(true, false, true); var navigatorMock = new Mock <Navigator>(); navigatorMock .SetupGet(it => it.Specification) .Returns(navigatorSpecs); var registry = new ScreenRegistry(); var manager = new NavigationManager(registry); manager.SetNavigator(navigatorMock.Object); // - Act var specs = manager.Specification; // - Assert Assert.IsNotNull(specs); Assert.AreEqual(navigatorSpecs, specs); navigatorMock.VerifyGet(it => it.Specification, Times.Once); }
public void SupportedBackToRootFactoryTest() { // - Arrange var registry = new ScreenRegistry(); var screenStack = new ScreenStack(); var specs = new NavigatorSpecification(false, true, false); var screenA = new Mock <Screen>().Object; var screenB = new ScreenStub(); screenStack.Push(screenB, screenA, screenA); var cf = new DefaultCommandsFactory(registry); // - Act var commands = cf.BackToRoot(screenStack, specs); // - Assert Assert.AreEqual(1, commands.Count); var command = commands.FirstOrDefault(); Assert.IsInstanceOf <BackToRootNavCommand>(command); }
public void SupportedReplaceFactoryTest() { // - Arrange var registry = new ScreenRegistry(); var screenStack = new ScreenStack(); var specs = new NavigatorSpecification(false, false, true); var screenA = new Mock <Screen>().Object; var screenB = new ScreenStub(); var screenBResolver = new Mock <IScreenResolver>().Object; registry.Register(typeof(ScreenStub), screenBResolver); screenStack.Push(screenB, screenA, screenA); var cf = new DefaultCommandsFactory(registry); // - Act var commands = cf.ReplaceScreen(screenStack, specs, screenB); // - Assert Assert.AreEqual(1, commands.Count); CollectionAssert.AllItemsAreInstancesOfType(commands, typeof(ReplaceScreenNavCommand)); }