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()); }
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()); }
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()); }
public void TestLogEntryException_AspectOnMethod() { var target = new LoggedMockA(); TestLogEntryException(target); }
public void TestLogConstructorExceptions_NoExeption() { var target = new LoggedMockA(false); Assert.AreEqual(0, logList.Logs.Count); }