示例#1
0
 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());
     }
 }
示例#2
0
        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());
            }
        }
示例#3
0
        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;
            }
        }
示例#4
0
 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;
     }
 }