コード例 #1
0
ファイル: NunitTestHtml.cs プロジェクト: elv1s42/NUnitGo
        public NunitTestHtml(NunitGoTest nunitGoTest, string testOutput = "")
        {
            Style       = GetStyle();
            ResultColor = nunitGoTest.GetColor();

            var strWr = new StringWriter();

            using (var writer = new HtmlTextWriter(strWr))
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Left, "0%");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "test-window");
                writer.AddAttribute(HtmlTextWriterAttribute.Title, Title);
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.WithAttr(HtmlTextWriterAttribute.Id, Id)
                .Tag(HtmlTextWriterTag.Div, () => writer
                     .Css(HtmlTextWriterStyle.TextAlign, "center")
                     .Css(HtmlTextWriterStyle.BackgroundColor, Colors.TestBorderColor)
                     .Css("padding", "20px")
                     .Css("margin", "0")
                     .CssShadow("0 0 20px -5px black")
                     .Tag(HtmlTextWriterTag.H2, () => writer
                          .Text($"{nunitGoTest.Name}. Result: ")
                          .Css("padding", "10px")
                          .Css(HtmlTextWriterStyle.BackgroundColor, ResultColor)
                          .Tag(HtmlTextWriterTag.Span, nunitGoTest.Result))
                     .Css("float", "right")
                     .Css("padding", "10px")
                     .Tag(HtmlTextWriterTag.Div, () => writer
                          .DangerButton("Back", "./../../" + Output.Files.TestListFile))
                     .Css("table-layout", "fixed")
                     .Css("word-break", "break-all")
                     .Css(HtmlTextWriterStyle.Width, "100%")
                     .Css(HtmlTextWriterStyle.BackgroundColor, Colors.BodyBackground)
                     .Css("border-spacing", "0")
                     .CssShadow("0 0 20px 0 " + Colors.TestBorderColor)
                     .Tag(HtmlTextWriterTag.Table, () => writer
                          .Css(HtmlTextWriterStyle.Width, "50%")
                          .Tag(HtmlTextWriterTag.Col)
                          .Css(HtmlTextWriterStyle.Width, "50%")
                          .Tag(HtmlTextWriterTag.Col)
                          .Tag(HtmlTextWriterTag.Tr, () => writer
                               .Css(HtmlTextWriterStyle.Width, "50%")
                               .Css(HtmlTextWriterStyle.BackgroundColor, Colors.White)
                               .Tag(HtmlTextWriterTag.Td, () => writer
                                    .AddTestResult(nunitGoTest))
                               .Css(HtmlTextWriterStyle.Width, "50%")
                               .Css(HtmlTextWriterStyle.BackgroundColor, Colors.White)
                               .Tag(HtmlTextWriterTag.Td, () => writer
                                    .AddTestHistory(nunitGoTest))
                               ))
                     .WithAttr(HtmlTextWriterAttribute.Id, "tabs-container")
                     .Tag(HtmlTextWriterTag.Div, () => writer
                          .WithAttr(HtmlTextWriterAttribute.Class, "tabs-menu")
                          .Tag(HtmlTextWriterTag.Ul, () => writer
                               .WithAttr(HtmlTextWriterAttribute.Class, "current")
                               .Tag(HtmlTextWriterTag.Li, () => writer
                                    .WithAttr(HtmlTextWriterAttribute.Href, "#test-screenshots-href")
                                    .Tag(HtmlTextWriterTag.A, "Screenshots"))
                               .Tag(HtmlTextWriterTag.Li, () => writer
                                    .WithAttr(HtmlTextWriterAttribute.Href, "#test-failure-href")
                                    .Tag(HtmlTextWriterTag.A, "Failure"))
                               .Tag(HtmlTextWriterTag.Li, () => writer
                                    .WithAttr(HtmlTextWriterAttribute.Href, "#test-environment-href")
                                    .Tag(HtmlTextWriterTag.A, "Test environment"))
                               .Tag(HtmlTextWriterTag.Li, () => writer
                                    .WithAttr(HtmlTextWriterAttribute.Href, "#test-output-href")
                                    .Tag(HtmlTextWriterTag.A, "Output"))
                               .Tag(HtmlTextWriterTag.Li, () => writer
                                    .WithAttr(HtmlTextWriterAttribute.Href, "#test-events-href")
                                    .Tag(HtmlTextWriterTag.A, "Test events"))
                               )
                          .WithAttr(HtmlTextWriterAttribute.Class, "test-tab")
                          .Tag(HtmlTextWriterTag.Div, () => writer
                               .WithAttr(HtmlTextWriterAttribute.Id, "test-screenshots-href")
                               .WithAttr(HtmlTextWriterAttribute.Class, "tab-content")
                               .Tag(HtmlTextWriterTag.Div, () => writer
                                    .AddScreenshots(nunitGoTest))
                               .WithAttr(HtmlTextWriterAttribute.Id, "test-failure-href")
                               .WithAttr(HtmlTextWriterAttribute.Class, "tab-content")
                               .Tag(HtmlTextWriterTag.Div, () => writer
                                    .AddFailure(nunitGoTest))
                               .WithAttr(HtmlTextWriterAttribute.Id, "test-environment-href")
                               .WithAttr(HtmlTextWriterAttribute.Class, "tab-content")
                               .Tag(HtmlTextWriterTag.Div, () => writer
                                    .AddEnvironment())
                               .WithAttr(HtmlTextWriterAttribute.Id, "test-output-href")
                               .WithAttr(HtmlTextWriterAttribute.Class, "tab-content")
                               .Tag(HtmlTextWriterTag.Div, () => writer
                                    .AddOutput(nunitGoTest, testOutput))
                               .WithAttr(HtmlTextWriterAttribute.Id, "test-events-href")
                               .WithAttr(HtmlTextWriterAttribute.Class, "tab-content")
                               .Tag(HtmlTextWriterTag.Div, () => writer
                                    .AddTestEvents(nunitGoTest)))
                          )
                     );

                writer.RenderEndTag(); //DIV
            }

            HtmlCode = strWr.ToString();
        }