I have two Iqueryables which have different values. I want to use FluentAssertions to compare the elements in the Iqueryable for my Unittests.
What I have is the following:
[Fact]
public void TestCompareIQueryables()
{
// Arrange
var objects1 = new CustomObject[]
{
new CustomObject {
Code = "Code1",
Name = "Name1"
}
}.AsQueryable();
var objects2 = new CustomObject []
{
new CustomObject {
Code = "Code2",
Name = "Name2"
}
}.AsQueryable();
// Assert
objects1.Should().HaveSameCount(objects2);
objects1.Should().BeEquivalentTo(objects1);
objects1.Should().BeEquivalentTo(objects2);
}
What is happening when I run this fact, is that it passes, but I expect the last Should().BeEquivalentTo() to fail.
Am I missing something that make the test not act as expected here? How can I compare each element to eachother in two IQueryables correctly?
Any help would be appreciated!