Exemple #1
0
        public void TestTwoScreens()
        {
            var ss = new ScreenStack();

            Assert.AreEqual(null, ss.CurrentScreen);
            var screen1 = new Screen();
            var screen2 = new Screen();

            ss.Push(screen1);
            ss.Update(0);
            Assert.AreSame(screen1, ss.CurrentScreen);

            screen1.Push(screen2);
            ss.Update(0);
            Assert.AreSame(screen2, ss.CurrentScreen);

            ss.Pop();
            ss.Update(0);
            Assert.AreSame(screen1, ss.CurrentScreen);

            ss.Pop();
            ss.Update(0);
            Assert.AreEqual(null, ss.CurrentScreen);

            Assert.Throws <InvalidOperationException>(ss.Pop);
        }
        public void PopScreenWhenEmptyTest()
        {
            // - Arrange
            var screenStack = new ScreenStack();

            // - Act & Assert
            Assert.Throws <InvalidOperationException>(
                () => screenStack.Pop());
        }
Exemple #3
0
        public void TestOneScreen()
        {
            var ss = new ScreenStack();

            Assert.AreEqual(null, ss.CurrentScreen);
            var screen = new Screen();

            ss.Push(screen);
            ss.Update(0);
            Assert.AreSame(screen, ss.CurrentScreen);
            ss.Pop();
            ss.Update(0);
            Assert.AreEqual(null, ss.CurrentScreen);
        }
Exemple #4
0
        public void Apply(Navigator navigator, ScreenStack screens)
        {
            var screen = screens.FirstOrDefault(e => e.GetType() == _screenType);

            if (screen is null)
            {
                throw new ScreenNotFoundException(_screenType);
            }

            while (screens.CurrentScreen != screen)
            {
                screens.Pop();
            }

            navigator.BackToScreen(screen);
        }
        public void PopScreenTest()
        {
            // - Arrange

            var screenA = new Mock <Screen>().Object;
            var screenB = new Mock <Screen>().Object;

            var screenStack = new ScreenStack();

            screenStack.Push(screenA, screenB);

            // - Act
            var removedScreen = screenStack.Pop();

            // - Assert
            Assert.IsTrue(screenStack.IsRoot);
            Assert.AreSame(screenA, screenStack.CurrentScreen);
            Assert.AreSame(screenB, removedScreen);
            CollectionAssert.DoesNotContain(screenStack, screenB);
            Assert.AreEqual(1, screenStack.Count);
        }
Exemple #6
0
 public void Apply(Navigator navigator, ScreenStack screens)
 {
     screens.Pop();
     screens.Push(_screen);
     navigator.Replace(_screen, _resolver);
 }
Exemple #7
0
 public void Apply(Navigator navigator, ScreenStack screens)
 {
     screens.Pop();
     navigator.Back();
 }