public void Can_retrieve_IAuthSession_with_global_ExcludeTypeInfo_set() { JsConfig.ExcludeTypeInfo = true; IAuthSession session = new CustomAuthSession { Id = "sess-1", UserAuthId = "1", Custom = "custom" }; var sessionKey = SessionFeature.GetSessionKey(session.Id); Cache.Set(sessionKey, session, HostContext.GetDefaultSessionExpiry()); var sessionCache = Cache.Get <IAuthSession>(sessionKey); Assert.That(sessionCache, Is.Not.Null); var typedSession = sessionCache as CustomAuthSession; Assert.That(typedSession, Is.Not.Null); Assert.That(typedSession.Custom, Is.EqualTo("custom")); JsConfig.ExcludeTypeInfo = false; }
public void Can_retrieve_TimeToLive_on_IAuthSession() { IAuthSession session = new CustomAuthSession { Id = "sess-1", UserAuthId = "1", Custom = "custom" }; var sessionKey = SessionFeature.GetSessionKey(session.Id); Cache.Remove(sessionKey); var ttl = Cache.GetTimeToLive(sessionKey); Assert.That(ttl, Is.Null); Cache.Set(sessionKey, session); ttl = Cache.GetTimeToLive(sessionKey); Assert.That(ttl.Value, Is.EqualTo(TimeSpan.MaxValue)); var sessionExpiry = HostContext.GetDefaultSessionExpiry(); Cache.Set(sessionKey, session, sessionExpiry); ttl = Cache.GetTimeToLive(sessionKey); Assert.That(ttl.Value, Is.GreaterThan(TimeSpan.FromSeconds(0))); Assert.That(ttl.Value, Is.LessThanOrEqualTo(sessionExpiry)); }
public void Can_retrieve_IAuthSession() { IAuthSession session = new CustomAuthSession { Id = "sess-1", UserAuthId = "1", Custom = "custom" }; var sessionKey = SessionFeature.GetSessionKey(session.Id); Cache.Set(sessionKey, session, HostContext.GetDefaultSessionExpiry()); var sessionCache = Cache.Get <IAuthSession>(sessionKey); Assert.That(sessionCache, Is.Not.Null); var typedSession = sessionCache as CustomAuthSession; Assert.That(typedSession, Is.Not.Null); Assert.That(typedSession.Custom, Is.EqualTo("custom")); }