Beispiel #1
0
        public void RemoveFromSessionDoesNotThrowForUnexistingKeys()
        {
            IStoryBoard board = new StoryBoardBase();

            board.StoreToSession(SessionId.Key1, "Caramel");

            Assert.DoesNotThrow(() => board.RemoveFromSession(SessionId.Key2));
        }
Beispiel #2
0
        public void WrongKeyDoesNotFindAnything()
        {
            IStoryBoard board = new StoryBoardBase();

            board.StoreToSession(SessionId.Key1, "Caramel");

            // Correctly read a string from the session
            bool res = board.TryLoadFromSession(SessionId.Key2, out string _);

            Assert.IsFalse(res);

            res = board.TryLoadFromSession(StepId.Step1, out string _);
            Assert.IsFalse(res);
        }
Beispiel #3
0
        public void RemoveFromSessionRemovesExistingKey()
        {
            IStoryBoard board = new StoryBoardBase();

            board.StoreToSession(SessionId.Key1, "Caramel");
            bool result = board.TryLoadFromSession(SessionId.Key1, out string value);

            Assert.IsTrue(result);
            Assert.AreEqual("Caramel", value);

            board.RemoveFromSession(SessionId.Key1);
            result = board.TryLoadFromSession(SessionId.Key1, out value);
            Assert.IsFalse(result);
        }
Beispiel #4
0
        public void StartRunsTheFirstStep()
        {
            Mock <IStoryBoardStep> step1 = new Mock <IStoryBoardStep>();
            Mock <IStoryBoardStep> step2 = new Mock <IStoryBoardStep>();

            IStoryBoard board = new StoryBoardBase();

            board.RegisterStep(step1.Object);
            board.RegisterStep(step2.Object);

            board.Start();

            step1.Verify(x => x.Run(), Times.Once);
            step2.Verify(x => x.Run(), Times.Never);
        }
Beispiel #5
0
        public void LoadingFromSessionRequiresCorrectType()
        {
            IStoryBoard board = new StoryBoardBase();

            board.StoreToSession(SessionId.Key1, "Caramel");

            // Correctly read a string from the session
            bool res = board.TryLoadFromSession(SessionId.Key1, out string stringValue);

            Assert.IsTrue(res);
            Assert.AreEqual("Caramel", stringValue);

            // Wrongly read an int from the session
            res = board.TryLoadFromSession(SessionId.Key1, out int intValue);
            Assert.IsFalse(res);
        }
Beispiel #6
0
        public void ContinuesWithRunsCorrectStep()
        {
            Mock <IStoryBoardStep> step1 = new Mock <IStoryBoardStep>();

            step1.SetupGet(x => x.Id).Returns(StepId.Step1);
            Mock <IStoryBoardStep> step2 = new Mock <IStoryBoardStep>();

            step2.SetupGet(x => x.Id).Returns(StepId.Step2);

            IStoryBoard board = new StoryBoardBase();

            board.RegisterStep(step1.Object);
            board.RegisterStep(step2.Object);

            board.ContinueWith(StepId.Step2);

            step1.Verify(x => x.Run(), Times.Never);
            step2.Verify(x => x.Run(), Times.Once);
        }