/// <summary> /// 设置上下文存储对象 /// </summary> /// <param name="storage"></param> public static void SetStorage(IThreadStorage storage) { if (storage == null) { throw new ArgumentNullException("storage is null"); } threadStorage = storage; }
public void TearDown() { // cleanup storage IThreadStorage storage = CreateStorage(); storage.FreeNamedDataSlot("key"); storage.FreeNamedDataSlot("KEY"); storage.FreeNamedDataSlot("KeY"); }
public void FreeNamedDataSlotRemovesData() { IThreadStorage storage = CreateStorage(); object value1 = new object(); storage.SetData("key", value1); Assert.AreSame(value1, storage.GetData("key")); storage.FreeNamedDataSlot("key"); Assert.AreSame(null, storage.GetData("key")); }
public void AllowReplaceData() { IThreadStorage storage = CreateStorage(); object value1 = new object(); object value2 = new object(); storage.SetData("key", value1); Assert.AreSame(value1, storage.GetData("key")); storage.SetData("key", value2); Assert.AreSame(value2, storage.GetData("key")); storage.SetData("key", null); Assert.AreSame(null, storage.GetData("key")); }
public void UsesDistinguishedStorageOnDifferentThreads() { IThreadStorage storage = CreateStorage(); object value1 = new object(); storage.SetData("key", value1); ThreadTestHelper helper = new ThreadTestHelper(this, storage); helper.Execute(); Assert.AreNotSame(value1, helper.value); Assert.IsNull(helper.value); }
public void IsCaseSensitive() { IThreadStorage storage = CreateStorage(); object value1 = new object(); object value2 = new object(); object value3 = new object(); storage.SetData("key", value1); storage.SetData("KEY", value2); storage.SetData("KeY", value3); Assert.AreSame(value1, storage.GetData("key")); Assert.AreSame(value2, storage.GetData("KEY")); Assert.AreSame(value3, storage.GetData("KeY")); }
public ReportLogic(IStudentStorage studentStorage, IStudyingStatusStorage studyingStatusStorage, IThreadStorage threadStorage) { this.studentStorage = studentStorage; this.studyingStatusStorage = studyingStatusStorage; this.threadStorage = threadStorage; }
/// <summary> /// Set the new <see cref="IThreadStorage"/> strategy. /// </summary> public static void SetStorage(IThreadStorage storage) { AssertUtils.ArgumentNotNull(storage, "storage"); threadStorage = storage; }
/// <summary> /// Set the new <see cref="IThreadStorage"/> strategy. /// </summary> public static void SetStorage(IThreadStorage storage) { threadStorage = storage; }
public ThreadTestHelper(CommonThreadStorageTests outer, IThreadStorage storage) { this.outer = outer; this.storage = storage; }
public void UnknownKeyReturnsNull() { IThreadStorage storage = CreateStorage(); Assert.AreSame(null, storage.GetData("key")); }
public ThreadLogic(IThreadStorage ThreadStorage) { storage = ThreadStorage; }
/// <summary> /// Set the new <see cref="IThreadStorage"/> strategy. /// </summary> public static void SetStorage(IThreadStorage storage) { Guard.ArgumentNotNull(storage, "storage"); threadStorage = storage; }