コード例 #1
0
        public void RemoveTest()
        {
            ThreadLogContext target = Log.ThreadContext;
            string           key    = "RemoveTest";

            target[key] = 1;
            Assert.AreEqual(true, target.ContainsKey(key));
            target.Remove(key);
            Assert.AreEqual(false, target.ContainsKey(key));
        }
コード例 #2
0
        public void ItemTest()
        {
            ThreadLogContext target = Log.ThreadContext;
            string           key    = "ItemTest";
            int expected            = 123;

            target[key] = expected;
            int actual = (int)target[key];

            Assert.AreEqual(expected, actual);
            target.Remove(key);
        }
コード例 #3
0
        public void TryGetValueTest()
        {
            ThreadLogContext target = Log.ThreadContext;
            string           key    = "TryGetValueTest";

            target[key] = 1;
            if (target.TryGetValue(key, out int value))
            {
                Assert.AreEqual(1, value);
            }
            else
            {
                Assert.Fail("The key (" + key + ") should have been found.");
            }
            target.Remove(key);
            if (target.TryGetValue("Missing", out string _))
            {
                Assert.Fail("The 'Missing' key should NOT be found.");
            }
        }