So as you may have noticed, I really love lambdas. Having the possibility to write code like the row below makes my code more readable.
List<Person> people = peopleRepository.FindAllByName("Thomas"); int totalAge = people.Sum(person => person.Age);
So I would like to use lambdas and list iterations to assert things in NUnit, e.g. like this:
Assert.Contains(people, person => person.FirstName == "Thomas" && person.LastName == "Lundström", "The list should contain Thomas Lundström");
That way it's way much more readable than how I have to do to get the same functionality today:
Assert.AreEqual(1, people.FindAll(person => person.FirstName == "Thomas" && person.LastName == "Lundström").Count, "The list should contain Thomas Lundström");
I think it would be a fun project to implement it.
0 kommentarer:
Post a Comment