コード例 #1
0
ファイル: ListComparisonFormatter.cs プロジェクト: ywscr/NBi
        public StringBuilder Format(ListComparer.Result result)
        {
            var sb = new StringBuilder();

            Format("missing", result.Missing, result.MissingCount, ref sb);
            Format("unexpected", result.Unexpected, result.UnexpectedCount, ref sb);
            return(sb);
        }
コード例 #2
0
        public void Compare_NoUnexpected_UnexpectedNotVisible()
        {
            var res = new ListComparer.Result(
                new List<string> { "a", "b", "c" },
                null
                );

            var formatter = new ListComparisonFormatter();
            var display = formatter.Format(res).ToString();

            Assert.That(display, Is.StringContaining("No unexpected"));
        }
コード例 #3
0
        public void Compare_BothEmpty_CorrectDisplay()
        {
            var res = new ListComparer.Result(
                new List<string> { },
                new List<string> { }
                );

            var formatter = new ListComparisonFormatter();
            var display = formatter.Format(res).ToString();

            Assert.That(display, Is.StringContaining("No missing item"));
            Assert.That(display, Is.StringContaining("No unexpected item"));
        }
コード例 #4
0
        public void Compare_MultipleMissing_Plural()
        {
            var res = new ListComparer.Result(
                new List<string> { "a", "b", "c" },
                null
                );

            var formatter = new ListComparisonFormatter();
            var display = formatter.Format(res).ToString();

            Assert.That(display, Is.StringContaining("Missing items"));
            Assert.That(display, Is.StringContaining("<a>"));
            Assert.That(display, Is.StringContaining("<b>"));
            Assert.That(display, Is.StringContaining("<c>"));
        }
コード例 #5
0
        public void RenderCompared_WithSpecialRows_DisplayTextForThisKindOfRows(
            int missingRowCount
            , int unexpectedRowCount
            , string expectedText)
        {
            var compared = new ListComparer.Result(
                    GetDataRows(missingRowCount)
                    , GetDataRows(unexpectedRowCount)
                );

            var msg = new ItemsMessage(FailureReportProfile.Default);
            msg.Build(null, null, compared);
            var value = msg.RenderCompared();

            Assert.That(value, Is.StringContaining(expectedText));
        }
コード例 #6
0
        public void Compare_Mix_CorrectDisplay()
        {
            var res = new ListComparer.Result(
                new List<string> { "x" },
                new List<string> { "a", "b", "c" }
                );

            var formatter = new ListComparisonFormatter();
            var display = formatter.Format(res).ToString();

            Assert.That(display, Is.Not.StringContaining("Missing items"));
            Assert.That(display, Is.StringContaining("Missing item"));
            Assert.That(display, Is.StringContaining("Unexpected items"));
            Assert.That(display, Is.StringContaining("<x>"));
            Assert.That(display, Is.StringContaining("<a>"));
            Assert.That(display, Is.StringContaining("<b>"));
            Assert.That(display, Is.StringContaining("<c>"));
        }