public void ExceptionThrownInTracedActionAsyncShouldAddErrorTagAndRethrow() { var trace = Trace.Create(); trace.ForceSampled(); Trace.Current = trace; var baseStandardTrace = new BaseStandardTrace { Trace = trace }; var ex = new Exception("something bad happened"); Task task = Task.Run(() => { try { return; } finally { throw ex; } }); Assert.ThrowsAsync <Exception>(() => baseStandardTrace.TracedActionAsync(task)); VerifyDispatcherRecordedAnnotation(new TagAnnotation("error", ex.Message)); }
public void ShouldLogAnnotation() { // Arrange dispatcher .Setup(h => h.Dispatch(It.IsAny <Record>())) .Returns(true); var trace = Trace.Create(); trace.ForceSampled(); Trace.Current = trace; var baseStandardTrace = new BaseStandardTrace { Trace = trace }; // Act baseStandardTrace.AddAnnotation(Annotations.WireSend()); // Assert dispatcher .Verify(h => h.Dispatch(It.Is <Record>(m => m.Annotation is WireSend))); }
public void ExceptionThrownInTracedActionAsyncTShouldBeRethrownWhenCurrentTraceIsNull() { Trace.Current = null; var baseStandardTrace = new BaseStandardTrace(); Task <object> task = Task.Run <object>(() => throw new SomeException()); Assert.ThrowsAsync <SomeException>(() => baseStandardTrace.TracedActionAsync(task)); }