shouldly / shouldly

Should testing for .NET—the way assertions should be!

Home Page:https://docs.shouldly.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If I use ShouldBe to compare a list of KeyValuePair and a dictionary I get no error

Messoz opened this issue · comments

Hello,
This test has success result. Shouldn't an assertion of this kind fail?


[Fact]
    public async Task ShouldBeProblem()
    {
        var list_kv = new List<KeyValuePair<string, string>>
        {
            new("1", "2")
        };

        var dic = new Dictionary<string, string>()
        {
            {"1","2"}
        };
        
        list_kv.ShouldBe(dic);
    }

Shouldly Version 4.1.0

FrameWorks And Dependency
.NETStandard 2.0       
 DiffEngine ≥ 10.0.0        
EmptyFiles ≥ 2.8.0        
Microsoft.CSharp ≥ 4.7.0

I don't think it should fail. It's pretty common for .ShouldBe(new[] { 1, 2 }) or similar to be used on a collection that isn't an array necessarily, for instance. If the exact type matters, that should be an explicit additional .ShouldBeOfType<List<KeyValuePair<string, string>>>() assertion.