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

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

            Assert.DoesNotThrow(() => board.RemoveFromSession(SessionId.Key2));
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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);
        }