0

I have expected and actual responses that look like JSON objects by default. In my case there are two lists. I have to verify that this two lists have at list one the same element.

Function should be look like:

(expectedResponse, actualResponse) => ((List<Question>)actualResponse.Body).Should()
                        .NotIntersectWith(((List<Question>)expectedResponse.Body))
Bazaka Bazaka
  • 135
  • 11

1 Answers1

0

From their wiki, you can use IntersectWith method:

IEnumerable otherCollection = new[] { 1, 2, 5, 8, 1 };
IEnumerable anotherCollection = new[] { 10, 20, 50, 80, 10 };
collection.Should().IntersectWith(otherCollection);

Make sure that objects in collection properly implement IEquatable<T> interface (optionaly) and Equals method (required).

Andrii Litvinov
  • 12,402
  • 3
  • 52
  • 59