public void LogEvent_NoExecption_DoesNotCallClient() { var client = A.Fake<ISharpbrakeClient>(); AirBrakeTarget target = new AirBrakeTarget(client); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); logger.Info("no exception with this one."); A.CallTo(() => client.Send(A<AirbrakeNotice>.Ignored)).MustNotHaveHappened(); }
public void LogEvent_NoExecption_DoesNotCallClient() { var client = A.Fake <ISharpbrakeClient>(); AirBrakeTarget target = new AirBrakeTarget(client); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); logger.Info("no exception with this one."); A.CallTo(() => client.Send(A <AirbrakeNotice> .Ignored)).MustNotHaveHappened(); }
public void LogEvent_WithExecption_CallsClient() { var client = A.Fake<IAirbrakeClient>(); AirBrakeTarget target = new AirBrakeTarget(client); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); Exception ex = new ApplicationException("something bad happened"); logger.InfoException("kaboom", ex); A.CallTo(() => client.Send(ex)).MustHaveHappened(); }
public void LogEvent_WithExecption_CallsClient() { var client = A.Fake<ISharpbrakeClient>(); Exception ex = new ApplicationException("something bad happened"); // using activator to avoid the obsolete tag on the constructor. AirbrakeError error = Activator.CreateInstance<AirbrakeError>(); AirbrakeNotice notice = new AirbrakeNotice() { Error = error }; A.CallTo(() => client.BuildNotice(ex)).Returns(notice); AirBrakeTarget target = new AirBrakeTarget(client); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); logger.InfoException("kaboom", ex); A.CallTo(() => client.Send(notice)).MustHaveHappened(); }
public void AirBrakeTarget_InnerException_CreateBackTrace() { AirBrakeTarget target = new AirBrakeTarget(); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); try { new InnerExceptionTestHelper().ThrowException(); } catch(Exception ex) { List<AirbrakeTraceLine> traceLines = new List<AirbrakeTraceLine>(); if (ex.InnerException != null) { traceLines = target.GetBackTraceLines(ex, 1); } Assert.True(traceLines.Count == 12); } }
public void AirBrakeTarget_InnerException_CreateBackTrace() { AirBrakeTarget target = new AirBrakeTarget(); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); try { new InnerExceptionTestHelper().ThrowException(); } catch (Exception ex) { List <AirbrakeTraceLine> traceLines = new List <AirbrakeTraceLine>(); if (ex.InnerException != null) { traceLines = target.GetBackTraceLines(ex, 1); } Assert.Equal(10, traceLines.Count); } }
public void LogEvent_WithExecption_CallsClient() { var client = A.Fake <ISharpbrakeClient>(); Exception ex = new ApplicationException("something bad happened"); // using activator to avoid the obsolete tag on the constructor. AirbrakeError error = Activator.CreateInstance <AirbrakeError>(); AirbrakeNotice notice = new AirbrakeNotice() { Error = error }; A.CallTo(() => client.BuildNotice(ex)).Returns(notice); AirBrakeTarget target = new AirBrakeTarget(client); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); logger.InfoException("kaboom", ex); A.CallTo(() => client.Send(notice)).MustHaveHappened(); }