question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should().AllBeEquivalentTo does not work on List<String>

See original GitHub issue

Should().AllBeEquivalentTo works for Lists of various types, but appears not to work for List<String>, in version 5.10.2

This is very easy to reproduce. In a new Net Framekwork 4.7.2 app, add these two lines of code to any event handler:

new List<int> { 1, 2, 3 }.Should().AllBeEquivalentTo(new List<int> { 1, 2, 3 });
new List<String> { "a", "b", "c" }.Should().AllBeEquivalentTo(new List<String> { "foo", "bar" });

The first line generates no errors, the second line generates 'StringCollectionAssertions' does not contain a definition for 'AllBeEquivalentTo' and no accessible extension method 'AllBeEquivalentTo' accepting a first argument of type 'StringCollectionAssertions' could be found (are you missing a using directive or an assembly reference?)

It seems like I must be missing something very obvious, but the documentation does not say that there are special requirements for List<String>

I see that in the case of List<int> GenericCollectionAssertions is providing the assertion, but the error for List<string> implies that the reference is trying to be resolved against StringCollectionAssertions - is this a separate module?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rynkevichcommented, May 25, 2020

@dennisdoomen, I’ve pushed changes where this method is renamed to AllBe.

1reaction
rynkevichcommented, May 23, 2020

I think that string collections should also support this functionality, so I’ve provided a PR to add it. @jnyrup, @dennisdoomen I would be glad if you take a look at it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Fluent Assertions ShouldAllBeEquivalentTo
to assert that all instances of OrderDto are structurally equal to a single object: orderDtos.Should().AllBeEquivalentTo(singleOrder);.
Read more >
ShouldAllBeEquivalentTo and Excluding is not working ...
When you use the extension ShouldAllBeEquivalentTo on enumerable and also want to exclude a property then it's not working properly.
Read more >
Just Use FluentAssertions - Tinkerer
Seeing as our classes don't implement Equals() there's not really any good way for the built-in libraries to see if they're equal to...
Read more >
[Solved]-Comparing Collections Fluent Assertions Should All ...
Should().AllBeEquivalentTo(expected) has now been implemented in FluentAssertions: ... I am continuously querying database; should there be any problem?
Read more >
Collections
AllBeEquivalentTo (referenceObject);. In case if you need to perform individual assertions on all elements of a collection, you can assert each element ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found