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); }
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); }
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); }