Esempio n. 1
0
        public void StorageIsUsedByFacadeMethods()
        {
            MockStorage storage = new MockStorage();

            LogicalThreadContext.SetStorage(storage);

            object value = new object();

            LogicalThreadContext.SetData("key", value);
            Assert.AreSame(value, storage.data["key"]);

            object data = LogicalThreadContext.GetData("key");

            Assert.AreSame(value, data);

            LogicalThreadContext.FreeNamedDataSlot("key");

            Assert.IsFalse(storage.data.ContainsKey("key"));
        }
Esempio n. 2
0
 public void StorageMayBeSetMoreThanOnce()
 {
     LogicalThreadContext.SetStorage(new MockStorage());
     LogicalThreadContext.SetStorage(new MockStorage());
     LogicalThreadContext.SetStorage(new MockStorage());
 }
Esempio n. 3
0
 public void StorageMustNotBeNull()
 {
     Assert.Throws <ArgumentNullException>(() => LogicalThreadContext.SetStorage(null));
 }