Пример #1
0
        public void right(ICellWrapper <Parse> expected, RestDataTypeAdapter typeAdapter)
        {
            string expectedContent = expected.body();

            expected.body(Tools.HtmlTools.makeContentForRightCell(expectedContent, typeAdapter, this, minLenForToggle));
            fixture.Right(expected.Wrapped);
        }
Пример #2
0
        /// <param name="expected">        the expected value </param>
        /// <param name="typeAdapter">     the body type adaptor </param>
        /// <param name="formatter">       the formatter
        ///                        the value determining whether the content should be rendered
        ///                        as a collapseable section. </param>
        /// <param name="minLenForToggle"> the value determining whether the content should be rendered
        ///                        as a collapseable section. </param>
        /// <returns> the formatted content for a cell with a right expectation </returns>
        public static string makeContentForRightCell <T1>(string expected, RestDataTypeAdapter typeAdapter,
                                                          ICellFormatter <T1> formatter, int minLenForToggle)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(HtmlTools.toHtml(expected));
            string actual = typeAdapter.ToString();

            if (formatter.DisplayActual && !expected.Equals(actual))
            {
                sb.Append(HtmlTools.toHtml("\n"));
                sb.Append(formatter.label("expected"));
                sb.Append(HtmlTools.toHtml("-----"));
                sb.Append(HtmlTools.toHtml("\n"));
                if (minLenForToggle >= 0 && actual.Length > minLenForToggle)
                {
                    sb.Append(makeToggleCollapseable("toggle actual", HtmlTools.toHtml(actual)));
                }
                else
                {
                    sb.Append(HtmlTools.toHtml(actual));
                }
                sb.Append(HtmlTools.toHtml("\n"));
                sb.Append(formatter.label("actual"));
            }
            return(sb.ToString());
        }
Пример #3
0
        public void wrong(ICellWrapper <String> expected, RestDataTypeAdapter ta)
        {
            string expectedContent = expected.body();

            expected.body(Tools.HtmlTools.makeContentForWrongCell(expectedContent, ta, this, minLenForToggle));
            expected.body("fail:" + HtmlTools.wrapInDiv(expected.body()));
        }
Пример #4
0
        public void wrong(ICellWrapper <Parse> expected, RestDataTypeAdapter typeAdapter)
        {
            string expectedContent = expected.body();
            string body            = Tools.HtmlTools.makeContentForWrongCell(expectedContent, typeAdapter, this, minLenForToggle);

            expected.body(body);
            fixture.Wrong(expected.Wrapped);
        }
Пример #5
0
        /// <param name="expected">        the expected value </param>
        /// <param name="typeAdapter">     the body adapter for the cell </param>
        /// <param name="formatter">       the formatter </param>
        /// <param name="minLenForToggle"> the value determining whether the content should be rendered
        ///                        as a collapseable section. </param>
        /// <returns> the formatted content for a cell with a wrong expectation </returns>
        public static string makeContentForWrongCell <T1>(string expected, RestDataTypeAdapter typeAdapter,
                                                          ICellFormatter <T1> formatter, int minLenForToggle)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(HtmlTools.toHtml(expected));
            if (formatter.DisplayActual)
            {
                sb.Append(HtmlTools.toHtml("\n"));
                sb.Append(formatter.label("expected"));
                string actual = typeAdapter.ToString();
                sb.Append(HtmlTools.toHtml("-----"));
                sb.Append(HtmlTools.toHtml("\n"));
                if (minLenForToggle >= 0 && actual.Length > minLenForToggle)
                {
                    sb.Append(makeToggleCollapseable("toggle actual", HtmlTools.toHtml(actual)));
                }
                else
                {
                    sb.Append(HtmlTools.toHtml(actual));
                }
                sb.Append(HtmlTools.toHtml("\n"));
                sb.Append(formatter.label("actual"));
            }
            IReadOnlyList <string> errors = typeAdapter.Errors;

            if (errors.Count > 0)
            {
                sb.Append(HtmlTools.toHtml("-----"));
                sb.Append(HtmlTools.toHtml("\n"));
                foreach (string e in errors)
                {
                    sb.Append(HtmlTools.toHtml(e + "\n"));
                }
                sb.Append(HtmlTools.toHtml("\n"));
                sb.Append(formatter.label("errors"));
            }
            return(sb.ToString());
        }
Пример #6
0
        public void check(ICellWrapper <Parse> expected, RestDataTypeAdapter actual)
        {
            if (string.IsNullOrWhiteSpace(expected.body()))
            {
                if (actual.Actual == null)
                {
                    return;
                }
                else
                {
                    expected.body(gray(actual.Actual.ToString()));
                    return;
                }
            }

            if (actual.Actual != null && actual.Equals(expected.body(), actual.Actual.ToString()))
            {
                right(expected, actual);
            }
            else
            {
                wrong(expected, actual);
            }
        }
Пример #7
0
 public void right(ICellWrapper <String> expected, RestDataTypeAdapter typeAdapter)
 {
     expected.body("pass:" + HtmlTools.wrapInDiv(Tools.HtmlTools.makeContentForRightCell(expected.body(), typeAdapter, this, minLenForToggle)));
 }