Compare lists of same DTOs with different size using C# Fluent Assertions

Viewed 137

I am having this issue when I have two lists containing the same object type but with different sizes. I want to make sure they are being checked (one is sub list of the other for example) based on the all of the properties of the given DTO for example:

public class Student
{
    public int? id { get; set; }
    public string? name { get; set; }
}

And I have two lists for example:

List<Student> firstList = new List<Student>() { 
    new Student(){ Id = 1, Name="Bill"},
    new Student(){ Id = 2, Name="Steve"},
    new Student(){ Id = 3, Name="Ram"},
    new Student(){ Id = 4, Name="Abdul"}
};

List<Student> secondList = new List<Student>() { 
    new Student(){ Id = 1, Name="Bill"},
    new Student(){ Id = 4, Name="Abdul"}
};

So my question is how can I make an assertion with Fluent Assertion that secondList is a sub list of firstList using deep compare making sure all the properties of an objects are compared to each other.

Thank you for your time and attention!

0 Answers
Related