public void Should_Return_A_Null_Session() { var store = new SqlSessionStateStore(Constants.ConnectionString, Constants.SessionTimeout); var session = store.Load(_sessionId); session.ShouldBeNull(); }
public void Should_Load_An_Empty_Session_And_Unlock_It_Afterwards() { SessionDatabase.CreateSession(Constants.FullSessionId, Constants.SessionStateEmptySerializedBytes); var store = new SqlSessionStateStore(Constants.ConnectionString, Constants.SessionTimeout); var sessionState = store.Load(_sessionId); sessionState.ShouldEqual(Constants.SessionStateEmptySerializedBytes); var session = SessionDatabase.GetSession(Constants.FullSessionId); session.ShouldNotBeNull("No session found"); session.Locked.ShouldBeFalse(); }
public void Should_Concurrently_Load_A_Session_And_Unlock_It_Afterwards() { SessionDatabase.CreateSession(Constants.FullSessionId, ShortData); var store = new SqlSessionStateStore(Constants.ConnectionString, Constants.SessionTimeout); var results = new ConcurrentBag <bool>(); for (var i = 0; i < 20; i++) { ThreadPool.QueueUserWorkItem( x => results.Add((store.Load(_sessionId) ?? new byte[] {}).SequenceEqual(ShortData))); } while (results.Count < 20) { Thread.Sleep(100); } results.All(x => x).ShouldBeTrue(); }