Tag Archives: LINQ

GuardQ: Guard class meets Linq

Update: The code has moved to NetFx project at http://code.google.com/p/netfx/source/browse/trunk/Source/Guard.cs . In the task of validating function arguments, usually a sealed class Guard is created. For example, if we want to validate for null value the usual code is: public sealed class Guard { public static void ArgumentNotNull(object val, string argName) { if (val == null) … more

Posted in Blogs | Tagged |

Mocking with LINQ: Moq is here!

In these days of agile and TDD, most probably you had to deal with mocks. In such case, you have two options: create hundreds of mock classes by hand, one for each expected behavior for every unit test, or use a mock framework. There are many mock frameworks available for .NET but all of them … more

Posted in Blogs | Tagged , |

Prime generator with LINQ

Maybe this example is not impressive as an entire ray tracer in a single line, but it gives an idea of the expressiveness of LINQ. I remember from my high school times, the internal spontaneous competitions looking for the “fastest” prime generators. We were really far from the greatest and well known prime generators, but … more

Posted in Blogs | Tagged , |