private void ResponseXslt(HttpContextBase context, TestResultData results)
        {
            string xmlData;
            var xmlSer = new DataContractSerializer(typeof(TestResultData));

            using (var ms2 = new MemoryStream())
            {
                xmlSer.WriteObject(ms2, results);
                xmlData = Encoding.Default.GetString(ms2.ToArray());
                ms2.Close();
            }

            var xsltPath = VirtualPathUtility.ToAbsolute(XsltPath);

            XslCompiledTransform xslTransform = new XslCompiledTransform();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmlData);

            using (var writer = new StringWriter())
            {
                xslTransform.Load(context.Server.MapPath(xsltPath));
                xslTransform.Transform(doc.CreateNavigator(), null, writer);

                context.Response.ContentEncoding = Encoding.UTF8;
                context.Response.StatusCode = 200;
                context.Response.Write(writer.GetStringBuilder().ToString());
            }
        }
        private void ResponseXml(HttpContextBase context, TestResultData results)
        {
            string xmlData;
            var xmlSer = new DataContractSerializer(typeof(TestResultData));

            using (var ms1 = new MemoryStream())
            {
                xmlSer.WriteObject(ms1, results);
                xmlData = Encoding.Default.GetString(ms1.ToArray());
                ms1.Close();
            }

            context.Response.ContentType = "text/xml";
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.StatusCode = 200;
            context.Response.Write(xmlData);
        }
        private void ResponseJson(HttpContextBase context, TestResultData results)
        {
            string json;
            var jsonSer = new DataContractJsonSerializer(typeof(TestResultData));

            using (var ms = new MemoryStream())
            {
                jsonSer.WriteObject(ms, results);
                json = String.Concat("[", Encoding.Default.GetString(ms.ToArray()), "]");
                ms.Close();
            }

            context.Response.ContentType = "application/json";
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.StatusCode = 200;
            context.Response.Write(json);
        }
        private void ResponseOutput(HttpContextBase context, TestResultData results)
        {
            switch (ResponseOutputType)
            {
                case AvailableContentReturnTypes.json:
                    ResponseJson(context, results);
                    break;

                case AvailableContentReturnTypes.xml:
                    ResponseXml(context, results);
                    break;

                case AvailableContentReturnTypes.xslt:
                    ResponseXslt(context, results);
                    break;

                case AvailableContentReturnTypes.html:
                    ResponseHtml(context, results);
                    break;
            }
        }
        private void ResponseHtml(HttpContextBase context, TestResultData results)
        {
            string xmlData;
            var xmlSer = new DataContractSerializer(typeof(TestResultData));

            using (var ms3 = new MemoryStream())
            {
                xmlSer.WriteObject(ms3, results);
                xmlData = Encoding.Default.GetString(ms3.ToArray());
                ms3.Close();
            }

            using (var writer1 = new StringWriter())
            {
                XslCompiledTransform xslTransform1 = new XslCompiledTransform();
                XmlDocument doc1 = new XmlDocument();

                doc1.LoadXml(xmlData);

                Assembly asm = Assembly.GetExecutingAssembly();
                using (Stream rsrc = asm.GetManifestResourceStream("WebsiteUnitTestRunner.Testing.UnitTesting.Resources.default.xslt"))
                {
                    using (var xmlReader = new XmlTextReader(rsrc))
                    {
                        xslTransform1.Load(xmlReader);
                        xslTransform1.Transform(doc1.CreateNavigator(), null, writer1);
                    }
                }

                context.Response.ContentType = "text/html";
                context.Response.ContentEncoding = Encoding.UTF8;
                context.Response.StatusCode = 200;
                context.Response.Write(writer1.GetStringBuilder().ToString());
            }
        }