コード例 #1
0
        public void TestLogExplicitName()
        {
            const string expectedLogName = "MyLog";

            var target = new LoggedMockA();

            target.Other();

            Assert.AreEqual(2, logList.Logs.Count);
            Assert.AreEqual(expectedLogName, logList.Logs[0].GetLogName());
            Assert.AreEqual(expectedLogName, logList.Logs[1].GetLogName());
        }
コード例 #2
0
        public void TestLogAutoName()
        {
            const string expectedLogName = "PubComp.Aspects.Monitoring.UnitTests.LogMocks.LoggedMockA";

            var target = new LoggedMockA();

            try
            {
                target.ThrowSomething();
            }
            catch (ApplicationException)
            {
            }

            Assert.AreEqual(2, logList.Logs.Count);
            Assert.AreEqual(expectedLogName, logList.Logs[0].GetLogName());
            Assert.AreEqual(expectedLogName, logList.Logs[1].GetLogName());
        }
コード例 #3
0
        public void TestLogConstructorExceptions_Exception()
        {
            bool didCatchException = false;

            try
            {
                var target = new LoggedMockA(true);
            }
            catch (ApplicationException)
            {
                didCatchException = true;
            }

            Assert.AreEqual(1, logList.Logs.Count, "No log written");
            Assert.AreEqual(LogLevel.Error, logList.Logs[0].GetLevel(), "Log level is not Error");
            Assert.IsTrue(didCatchException, "Exception was not rethrown");

            var expectedCallSite = $"{typeof(LoggedMockA).FullName}..ctor";

            Assert.AreEqual(expectedCallSite, logList.Logs[0].GetCallSite());
        }
コード例 #4
0
        public void TestLogEntryException_AspectOnMethod()
        {
            var target = new LoggedMockA();

            TestLogEntryException(target);
        }
コード例 #5
0
        public void TestLogConstructorExceptions_NoExeption()
        {
            var target = new LoggedMockA(false);

            Assert.AreEqual(0, logList.Logs.Count);
        }