jeudi 22 janvier 2015

Make sure/check if property is selected in linq .Select() statement with unit test?

Assume I have the following class:



public class Person
{
public string FirstName{get;set;}
public string LastName{get;set;}
public int Age{get;set;}
}


Assume I have this query:



var persons = someListOfPersons.Where(r => r.Age > 18)
.Select(m => new Person(){m.LastName});


As we can see above, I am selecting new Person objects with only the LastName property actually selected. Note that at this point this is still just an IQueryable.


How can I unit test this, to make sure that the LastName property has been included in the select statement?


Aucun commentaire:

Enregistrer un commentaire