Should().ContainInOrder() - false negative?
See original GitHub issueVersion: 5.3.0
Exception / failure message:
Xunit.Sdk.XunitException: Expected collection {(KnownRoleTypes, System.Collections.Generic.List`1[System.Type]), (HostResultRun, ), (test1, ), (test2, ), (test3, )} to contain items {(test1, ), (test2, ), (test3, )} in order, but (test1, ) (index 0) did not appear (in the right order).
at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\XUnit2TestFramework.cs:line 32
at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 225
at FluentAssertions.Collections.CollectionAssertions`2.ContainInOrder(IEnumerable expected, String because, Object[] becauseArgs) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Collections\CollectionAssertions.cs:line 631
Code:
results.Events.Should().ContainInOrder(
new Tuple<string, object>("test1", null),
new Tuple<string, object>("test2", null),
new Tuple<string, object>("test3", null)
);
The exception seems to contradict itself - the collection does have those items?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
9 Fluent Assertions Tricks to Save Hours of Your Testing ...
Should().BeTrue(); }. The output message in this case is: Expected saveOperationResult to be true, but found False. Again, much clearer, right?
Read more >FluentAssertion, check constraint just for condition
You can choose to have a separate test for the positive (true) and negative (false) scenario. From a unit testing best practices document ......
Read more >Using matchers
String s and Array s as collections; Be as an equality comparison; Being negative; Checking that a snippet of code does not compile;...
Read more >FluentAssertions.Web
Asserts that a Bad Request HTTP response content contains an error message identifiable by an wildcard error text. Fine grained status assertions. Should()....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ran into a similar problem and found this issue. To repro in 6.1.0 do this:
The error is:
Please provide a complete example. It makes it harder to debug, when one has to guess the type and content of
result.events
.