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;
        }
Exemplo n.º 2
0
        public void Compare_Missing_MissingNullUnexpectedNotNull()
        {
            var listComparer = new ListComparer();
            var res = listComparer.Compare(
                new List<string> { "a", "b", "c" },
                new List<string> { "a", "b", "c" },
                ListComparer.Comparison.UnexpectedItems
                );

            Assert.That(res.Missing, Is.Null.Or.Empty);
            Assert.That(res.Unexpected, Is.Not.Null);
        }
Exemplo n.º 3
0
        public void Compare_MissingAndOneMissingItem_MissingHasCountOfOneWithCorrectMissingItem()
        {
            var listComparer = new ListComparer();
            var res = listComparer.Compare(
                new List<string> { "a", "b", "z"},
                new List<string> { "a", "b" },
                ListComparer.Comparison.Both
                );

            Assert.That(res.Missing, Has.Count.EqualTo(1));
            Assert.That(res.Missing.ElementAt(0), Is.EqualTo("z"));
        }
Exemplo n.º 4
0
        public void Compare_Both_MissingUnexpectedNotNull()
        {
            var listComparer = new ListComparer();
            var res = listComparer.Compare(
                new List<string> { "a", "b", "c" },
                new List<string> { "a", "b", "c" },
                ListComparer.Comparison.Both
                );

            Assert.That(res.Missing, Is.Not.Null);
            Assert.That(res.Unexpected, Is.Not.Null);
        }
Exemplo n.º 5
0
        public void Compare_BothWithMissingAndUnexpectedItems_MissingUnexpectedNotNullAndNotEmpty()
        {
            var listComparer = new ListComparer();
            var res = listComparer.Compare(
                new List<string> { "a", "b", "c" },
                new List<string> { "a", "b", "d" },
                ListComparer.Comparison.Both
                );

            Assert.That(res.Missing, Is.Not.Null.And.Not.Empty);
            Assert.That(res.Unexpected, Is.Not.Null.And.Not.Empty);
        }
        protected ItemsMessage BuildFailure()
        {
            var msg = new ItemsMessage(Configuration.FailureReportProfile);
            var compare = new ListComparer()
                        .Compare
                        (
                            ExpectedItems
                            , ((MemberResult)actual).ToCaptions()
                            , GetComparisonType()
                        );

            msg.Build(ExpectedItems, ((MemberResult)actual).ToCaptions(), compare);
            return msg;
        }
Exemplo n.º 7
0
        public void Compare_UnexpectedAndOneUnexpectedItem_UnexpectedHasCountOfOneWithCorrectUnexpectedItem()
        {
            var listComparer = new ListComparer();
            var res = listComparer.Compare(
                new List<string> { "a", "b" },
                new List<string> { "a", "b", "z" },
                ListComparer.Comparison.Both
                );

            Assert.That(res.Unexpected, Has.Count.EqualTo(1));
            Assert.That(res.Unexpected.ElementAt(0), Is.EqualTo("z"));
        }
Exemplo n.º 8
0
        public void Sample_LessThan10Items_DontThrowException()
        {
            var listComparer = new ListComparer();
            var res = listComparer.Compare(
                new List<string> { "a", "b", "c", "d", "e", "f", "g", "h" },
                new List<string> { "z" },
                ListComparer.Comparison.Both
                );

            var sampledRes = res.Sample(2);

            Assert.That(sampledRes.Missing.Count(), Is.EqualTo(2));
            Assert.That(sampledRes.MissingCount, Is.GreaterThan(2));

            Assert.That(sampledRes.Unexpected.Count(), Is.EqualTo(1));
            Assert.That(sampledRes.UnexpectedCount, Is.EqualTo(1));
        }