/// <summary> /// Create a session state for the tests /// </summary> /// <param name="st">The session content to populate with test data.</param> public void CreateSessionState(AspSessionContents st) { // Tableau object[] array = new object[3]; array[0] = "Yanal"; array[1] = "Joe"; array[2] = "Simon"; st.Add("keyarray", array); // Bool st.Add("keybool", true); // SingedByte sbyte sbyt = -12; st.Add("KeySignedByte", sbyt); // Unsigned byte byte byt = 12; st.Add("keybyte", byt); st.Add("keycur", new Currency(543)); st.Add("keydate", new DateTime(1962, 10, 19)); // double double doub = 3.23454; st.Add("keydbl", doub); // UnsingedShort" st["KeyUshort"] = (ushort)13; // Short short myshort = 12; st.Add("keyint", myshort); // UnsingedInteger st["KeyUInt"] = (uint)2434; // SingedInteger int myint = 25427; st.Add("keylng", myint); st.Add("keynull", null); // Single float mysing = 75.34211F; st.Add("keysng", mysing); // Decimal st["KeyDecimal"] = (decimal)234.456; // Date st.Add("keytime", new DateTime(1899, 12, 30, 04, 35, 47)); // Empty st["keyempty"] = new AspEmpty(); }
public void SerializeTest() { AspSessionPersistence persist = new AspSessionPersistence(); AspSessionContents st = new AspSessionContents(); this.CreateSessionState(st); var xml = persist.Serialize(st); Assert.AreEqual(xml, this.sessionXml); }
public void DeSerializeTest() { AspSessionPersistence persist = new AspSessionPersistence(); var sess = persist.Deserialize(this.sessionXml); var st = new AspSessionContents(); this.CreateSessionState(st); foreach (var item in sess) { object session_value = st[item.Key]; // st[item.Key].GetType() == item.value.GetType() Assert.AreEqual(item.Value, session_value); } }
public void RefreshSessionTest() { PartitionResolver pr = new PartitionResolver(); AspSessionPersistence persist = new AspSessionPersistence(); AspSessionContents st = new AspSessionContents(); this.CreateSessionState(st); var sessionid = persist.GenerateSessionId(); persist.SaveSession(sessionid, st, 20); persist.RefreshSession(sessionid); var sessionSaved = persist.LoadSession(sessionid); Assert.IsNotNull(sessionSaved); }
public void SaveSessionTest() { PartitionResolver pr = new PartitionResolver(); AspSessionPersistence persist = new AspSessionPersistence(); AspSessionContents st = new AspSessionContents(); this.CreateSessionState(st); var sessionid = persist.GenerateSessionId(); persist.SaveSession(sessionid, st, 20); var sessionSaved = persist.LoadSession(sessionid); foreach (var item in sessionSaved) { Assert.AreEqual(item.Value, st[item.Key]); } }