Ejemplo n.º 1
0
        public void GDCTest1()
        {
            GlobalDiagnosticsContext.Clear();
            Assert.False(GlobalDiagnosticsContext.Contains("foo"));
            Assert.Equal(string.Empty, GlobalDiagnosticsContext.Get("foo"));
            Assert.False(GlobalDiagnosticsContext.Contains("foo2"));
            Assert.Equal(string.Empty, GlobalDiagnosticsContext.Get("foo2"));
            Assert.Equal(0, GlobalDiagnosticsContext.GetNames().Count);

            GlobalDiagnosticsContext.Set("foo", "bar");
            GlobalDiagnosticsContext.Set("foo2", "bar2");

            Assert.True(GlobalDiagnosticsContext.Contains("foo"));
            Assert.Equal("bar", GlobalDiagnosticsContext.Get("foo"));
            Assert.Equal(2, GlobalDiagnosticsContext.GetNames().Count);

            GlobalDiagnosticsContext.Remove("foo");
            Assert.False(GlobalDiagnosticsContext.Contains("foo"));
            Assert.Equal(string.Empty, GlobalDiagnosticsContext.Get("foo"));

            Assert.True(GlobalDiagnosticsContext.Contains("foo2"));
            Assert.Equal("bar2", GlobalDiagnosticsContext.Get("foo2"));

            Assert.Equal(1, GlobalDiagnosticsContext.GetNames().Count);

            Assert.Null(GlobalDiagnosticsContext.GetObject("foo3"));
            Assert.Equal(string.Empty, GlobalDiagnosticsContext.Get("foo3", null));

            GlobalDiagnosticsContext.Set("foo3", new { One = 1 });
            Assert.NotNull(GlobalDiagnosticsContext.Get("foo3", null));
        }
Ejemplo n.º 2
0
        public static void SetVersion()
        {
            const string versionKey = "version";

            if (!GlobalDiagnosticsContext.Contains(versionKey))
            {
                GlobalDiagnosticsContext.Set(versionKey, GetVersion());
            }
        }
Ejemplo n.º 3
0
        public void GDCTest1()
        {
            GlobalDiagnosticsContext.Clear();
            Assert.IsFalse(GlobalDiagnosticsContext.Contains("foo"));
            Assert.AreEqual(string.Empty, GlobalDiagnosticsContext.Get("foo"));
            Assert.IsFalse(GlobalDiagnosticsContext.Contains("foo2"));
            Assert.AreEqual(string.Empty, GlobalDiagnosticsContext.Get("foo2"));

            GlobalDiagnosticsContext.Set("foo", "bar");
            GlobalDiagnosticsContext.Set("foo2", "bar2");

            Assert.IsTrue(GlobalDiagnosticsContext.Contains("foo"));
            Assert.AreEqual("bar", GlobalDiagnosticsContext.Get("foo"));

            GlobalDiagnosticsContext.Remove("foo");
            Assert.IsFalse(GlobalDiagnosticsContext.Contains("foo"));
            Assert.AreEqual(string.Empty, GlobalDiagnosticsContext.Get("foo"));

            Assert.IsTrue(GlobalDiagnosticsContext.Contains("foo2"));
            Assert.AreEqual("bar2", GlobalDiagnosticsContext.Get("foo2"));
        }