Exemple #1
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());
        }
Exemple #2
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());
        }