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 void RegisterRootScreen() { // - Arrange var screenClass = typeof(ScreenStub); var screenResolver = new Mock <IScreenResolver>().Object; var screenRegistry = new ScreenRegistry(); // - Act screenRegistry.Register(screenClass, screenResolver).AsRoot(); // - Assert Assert.IsFalse(screenRegistry.IsEmpty); Assert.AreSame(screenClass, screenRegistry.RootScreenClass !.Value.Type); Assert.IsTrue(screenRegistry.HasScreen(screenClass)); }
public void RegisterScreenTest() { // - Arrange var screenClass = typeof(ScreenStub); var screenResolver = new Mock <IScreenResolver>().Object; var screenRegistry = new ScreenRegistry(); // - Act screenRegistry.Register(screenClass, screenResolver); // - Assert Assert.IsFalse(screenRegistry.IsEmpty); Assert.IsNull(screenRegistry.RootScreenClass); Assert.IsTrue(screenRegistry.HasScreen(screenClass)); }
public void ResolveScreenFromRegistryTest() { // - Arrange var screenClass = typeof(ScreenStub); var screen = new ScreenStub(); var screenResolver = new Mock <IScreenResolver>().Object; var screenRegistry = new ScreenRegistry(); screenRegistry.Register(screenClass, screenResolver); // - Act var entry = screenRegistry.Resolve(screen); // - Assert Assert.IsNotNull(entry); Assert.AreSame(screenResolver, entry.Resolver); Assert.IsFalse(entry.IsRoot); }
public void ForwardFactoryTest() { // - Arrange var screen = new ScreenStub(); var resolver = new Mock <IScreenResolver>().Object; var registry = new ScreenRegistry(); registry.Register(typeof(ScreenStub), resolver); var cf = new DefaultCommandsFactory(registry); // - Act var commands = cf.Forward(screen); // - Assert Assert.AreEqual(1, commands.Count); var command = commands.FirstOrDefault(); Assert.IsNotNull(command); Assert.IsInstanceOf <ForwardNavCommand>(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)); }