Example #1
0
        public void Logging()
        {
            const int entry_count = 4;

            JsonServiceBase_Accessor target = new JsonServiceBase_Accessor(new PrivateObject(ts));
            StringBuilder            sb     = new StringBuilder();

            using (StringWriter sw = new StringWriter(sb)) {
                target.LogOutput = sw;
                target.Log(LogLevel.Info, "Logging Works: {0}", true);
            }

            string[] log = sb.ToString().Split('\t');
            if (log.Length != entry_count)
            {
                Assert.Fail("Log entry has an incorrect number of fields. Count: {0}, Expected: {1}", log.Length, entry_count);
            }

            DateTime dt;

            Assert.IsTrue(DateTime.TryParse(log[0], out dt));
            Assert.AreEqual(log[1], "User");
            Assert.AreEqual(log[2], "Info");
            Assert.IsTrue(log[3].StartsWith("Logging Works: True"));
            Assert.IsTrue(log[3].EndsWith("\n"));
        }
Example #2
0
        public void Logging()
        {
            const int entry_count = 4;

            JsonServiceBase_Accessor target = new JsonServiceBase_Accessor(new PrivateObject(ts));
            StringBuilder sb = new StringBuilder();
            using(StringWriter sw = new StringWriter(sb)) {
                target.LogOutput = sw;
                target.Log(LogLevel.Info, "Logging Works: {0}", true);
            }

            string[] log = sb.ToString().Split('\t');
            if(log.Length != entry_count)
                Assert.Fail("Log entry has an incorrect number of fields. Count: {0}, Expected: {1}", log.Length, entry_count);

            DateTime dt;
            Assert.IsTrue(DateTime.TryParse(log[0], out dt));
            Assert.AreEqual(log[1], "User");
            Assert.AreEqual(log[2], "Info");
            Assert.IsTrue(log[3].StartsWith("Logging Works: True"));
            Assert.IsTrue(log[3].EndsWith("\n"));
        }