Ejemplo n.º 1
0
        public void RunCodeInAppDomain(SerializableDelegate <Action <SimulatedHttpClient> > codeToRun, ConsoleWriter consoleWriter)
        {
            var client = new SimulatedHttpClient(consoleWriter);

            try
            {
                codeToRun.Delegate(client);
            }
            catch
            {
                if (!client.HadExpectedError())
                {
                    client.ConsoleWriter.WriteLine("Last response:\n\n" + SimulatedHttpClient.LastResponseText);
                }

                throw;
            }

            if (client.HadExpectedError())
            {
                throw new Exception("Expected error from HTTP client, but didn't get one");
            }
        }
        public void Test(Action <SimulatedHttpClient> testAction)
        {
            var serializableDelegate = new SerializableDelegate <Action <SimulatedHttpClient> >(testAction);

            _appDomainProxy.RunCodeInAppDomain(serializableDelegate, new ConsoleWriter());
        }