public void SimpleTraceTest() { ITracer tracer; using (tracer = TracerFactory.StartTracer(this, "Test", "Test")) { using (TracerFactory.StartTracer(this, "Inner1", "test")) { var item = new InnerTracerTest(); item.SomeMethod(); } using (TracerFactory.StartTracer(this, "Inner2", "test")) { var item = new InnerTracerTest(); item.SomeMethod(); } Assert.IsNull(tracer.ParentItem); Assert.IsNotNull(tracer.GetCallstack()); Assert.IsNotNull(tracer.GetCallstack().CallStack.FirstOrDefault()); } }
public async Task SimpleTraceAsyncTest() { try { ITracer tracer; using (tracer = TracerFactory.StartTracer(this, "Test", "Test")) { InnerTracerTest item = null; using (TracerFactory.StartTracer(this, "Inner2", "test")) { item = new InnerTracerTest(); item.SomeMethod(); await item.LoopAsync(); await item.SomeMethodAsync(); try { item.SomeMethodFail(); Debug.WriteLine("What?"); } catch (AggregateException agex) { Assert.IsInstanceOfType(agex.InnerException, typeof(NotImplementedException)); } catch (Exception ex) { var e = ex; Assert.IsInstanceOfType(ex, typeof(NotImplementedException)); } try { await item.SomeMethodFailAsync(); } catch (AggregateException agex) { Assert.IsInstanceOfType(agex.InnerException, typeof(NotImplementedException)); } catch (Exception ex) { var e = ex; Assert.IsInstanceOfType(ex, typeof(NotImplementedException)); } var t = item.NotAwaited(); Assert.IsFalse(item.asyncSet); await item.SomeMethodAsync(); await t; Assert.IsTrue(item.asyncSet); } Assert.IsNull(tracer.ParentItem); Assert.IsNotNull(tracer.GetCallstack()); Assert.IsNotNull(tracer.GetCallstack().CallStack.FirstOrDefault()); Assert.IsTrue(item.asyncFailedCalled); Assert.IsTrue(item.syncFailedCalled); } } catch (Exception ex) { ex.Log(); throw; } }
public async Task SimpleTraceAsyncTest() { try { ITracer tracer; using (tracer = TracerFactory.StartTracer(this, "Test", "Test")) { InnerTracerTest item = null; using (TracerFactory.StartTracer(this, "Inner2", "test")) { item = new InnerTracerTest(); item.SomeMethod(); await item.LoopAsync(); await item.SomeMethodAsync(); try { item.SomeMethodFail(); Debug.WriteLine("What?"); } catch (AggregateException agex) { Assert.IsInstanceOfType(agex.InnerException,typeof(NotImplementedException)); } catch (Exception ex) { var e = ex; Assert.IsInstanceOfType(ex, typeof(NotImplementedException)); } try { await item.SomeMethodFailAsync(); } catch (AggregateException agex) { Assert.IsInstanceOfType(agex.InnerException, typeof(NotImplementedException)); } catch (Exception ex) { var e = ex; Assert.IsInstanceOfType(ex, typeof(NotImplementedException)); } var t = item.NotAwaited(); Assert.IsFalse(item.asyncSet); await item.SomeMethodAsync(); await t; Assert.IsTrue(item.asyncSet); } Assert.IsNull(tracer.ParentItem); Assert.IsNotNull(tracer.GetCallstack()); Assert.IsNotNull(tracer.GetCallstack().CallStack.FirstOrDefault()); Assert.IsTrue(item.asyncFailedCalled); Assert.IsTrue(item.syncFailedCalled); } } catch (Exception ex) { ex.Log(); throw; } }