public void PolicyPerformsCorrelationThenReporting()
        {
            CorrelatedExceptionEventArgs finalArgs;

            using (IHost host = new IsolatedProcessHostFactory(RuntimeAccessor.Instance).CreateHost(new HostSetup(), new MarkupStreamLogger(TestLog.Default)))
            {
                HostAssemblyResolverHook.InstallCallback(host);
                finalArgs = (CorrelatedExceptionEventArgs)host.GetHostService().Do<object, object>(PolicyPerformsCorrelationThenReportingCallback, null);
            }

            Assert.IsNotNull(finalArgs);
            Assert.AreEqual("foo\nbar", finalArgs.Message);
            Assert.IsInstanceOfType<Exception>(finalArgs.Exception);
            Assert.IsFalse(finalArgs.IsRecursive);
        }
        public void PolicyHandlesUnhandledExceptionsAndRecursion()
        {
            List<CorrelatedExceptionEventArgs> args;

            using (IHost host = new IsolatedProcessHostFactory(RuntimeAccessor.Instance).CreateHost(new HostSetup(), new MarkupStreamLogger(TestLog.Default)))
            {
                HostAssemblyResolverHook.InstallCallback(host);
                args = (List<CorrelatedExceptionEventArgs>)host.GetHostService().Do<object, object>(PolicyHandlesUnhandledExceptionsAndRecursionCallback, null);
            }

            Assert.Count(3, args);
            Assert.AreEqual("Error.", args[0].Exception.Message);
            Assert.IsFalse(args[0].IsRecursive);
            Assert.AreEqual("Correlation error.", args[1].Exception.Message);
            Assert.IsTrue(args[1].IsRecursive);
            Assert.AreEqual("Reporting error.", args[2].Exception.Message);
            Assert.IsTrue(args[2].IsRecursive);
        }
        private IHost CreateHost()
        {
            var hostSetup = new HostSetup();
            hostSetup.Elevated = true;

            var hostFactory = new IsolatedProcessHostFactory(runtime);
            var host = hostFactory.CreateHost(hostSetup, runtime.Logger);
            return host;
        }