Skip to content

ShouldBe on two IEnumerables of different static types doesn't show differences #39

@xerxesb

Description

@xerxesb

If you call ShouldBe on two IEnumerable types, ShouldBe should show differences between the two collections.

However if the two IEnumerables are of different runtime types (eg: Array and List) the difference highlighter does not kick in and show what was different between the two IEnumerables even thought it should be perfectly able to do so.

Tests speak louder than rambling...

        [Test]
        public void ShouldBe_EnumerableTypesOfDifferentRuntimeTypes_ShouldShowDifferences()
        {
            var a = new Widget { Name = "Joe", Enabled = true };
            var b = new Widget { Name = "Joeyjojoshabadoo Jr", Enabled = true };

            IEnumerable<Widget> aEnumerable = a.ToEnumerable();
            IEnumerable<Widget> bEnumerable = new[] { b };

            Should.Error(() =>
                aEnumerable.ShouldBe(bEnumerable),
                "aEnumerable should be [Name(Joeyjojoshabadoo Jr) Enabled(True)] but was [Name(Joe) Enabled(True)] difference [*Name(Joe) Enabled(True)*]"
            );
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions