コード例 #1
0
        public void ErrorTelemetryEventsContainAllDataOnAsyncCall()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <AsyncService, IAsyncService>()
                       .ShouldWaitForCompletion();

            using ( host )
            {
                host.Open();
                IAsyncService client = host.GetChannel();
                try
                {
                    client.FailWithFaultAsync().Wait();
                } catch
                {
                }
            }
            var error = (from item in TestTelemetryChannel.CollectedData()
                         where item is ExceptionTelemetry
                         select item).Cast <ExceptionTelemetry>().First();

            Assert.IsNotNull(error.Exception);
            Assert.IsNotNull(error.Context.Operation.Id);
            Assert.IsNotNull(error.Context.Operation.Name);
        }
コード例 #2
0
        public void ErrorTelemetryEventsAreGeneratedOnAsyncFault()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <AsyncService, IAsyncService>()
                       .ShouldWaitForCompletion();

            using (host)
            {
                host.Open();
                IAsyncService client = host.GetChannel();
                try
                {
                    client.FailWithFaultAsync().Wait();
                }
                catch
                {
                }
            }

            var errors = from item in TestTelemetryChannel.CollectedData()
                         where item is ExceptionTelemetry
                         select item;

            Assert.IsTrue(errors.Count() > 0);
        }