Exemplo n.º 1
0
        private void TestLogEntryExit(ILoggedMock target)
        {
            target.Short();

            Assert.AreEqual(2, logList.Logs.Count);
            Assert.AreEqual(LogLevel.Trace, logList.Logs[0].GetLevel());
            Assert.AreEqual(LogLevel.Trace, logList.Logs[1].GetLevel());

            var expectedCallSite = $"{target.GetType().FullName}.{nameof(target.Short)}";

            Assert.AreEqual(expectedCallSite, logList.Logs[0].GetCallSite());
            Assert.AreEqual(expectedCallSite, logList.Logs[1].GetCallSite());
        }
Exemplo n.º 2
0
        private void TestLogEntryException(ILoggedMock target)
        {
            bool caughtException = false;

            try
            {
                target.ThrowSomething();
            }
            catch (ApplicationException)
            {
                caughtException = true;
            }

            Assert.IsTrue(caughtException);

            Assert.AreEqual(2, logList.Logs.Count);
            Assert.AreEqual(LogLevel.Trace, logList.Logs[0].GetLevel());
            Assert.AreEqual(LogLevel.Error, logList.Logs[1].GetLevel());

            var expectedCallSite = $"{target.GetType().FullName}.{nameof(target.ThrowSomething)}";

            Assert.AreEqual(expectedCallSite, logList.Logs[0].GetCallSite());
            Assert.AreEqual(expectedCallSite, logList.Logs[1].GetCallSite());
        }