• .NET

    JustMock. The tale continues... (Part 4)

    Last time we saw how to inject code in properties and static methods (including ones defined in static types). So far we are able to inject code in most common scenarios. In rare cases there is a need to isolate methods from mscorlib. In this post I will show you how do to this. Let's start with a demo program that I will explain in...
  • .NET

    Mocking LINQ to SQL [Continued…] using RLINQ

    After making the post on mocking LINQ to SQL, this morning i was having a chat with Stephen forte and come to know that telerik a has product named RLINQ. RLINQ is built on top of OpenAccess and it supports variety of databases. Being curious, i thought of giving a spin with it and may be try to mock its LINQ to SQL implementation using JustMock.   Now, before i start, i also found that OpenAccess has a free / express version that works on top express database [Ex.sqlexpress] but supports all the features that full version offers. I will be using the...
    July 29, 2010
  • .NET

    JustMock. The tale continues... (Part 3)

    Last time we saw how we can inject code at the beginning of generic methods. Today I will show you how to inject code in properties. I will cover the syntax for static classes as well. So, let's start with a demo program that I will explain line-by-line. using System; using Telerik.CodeWeaver.Hook;   namespace ConsoleApplication4 {     public sealed class TargetClass1     {         public TargetClass1(string text)         {             Text = InitText = text;         }           public string InitText { get; private set;...
  • .NET

    Unit testing LINQ to SQL

    Unit testing LINQ to SQL repositories can be very challenging. Unit testing such requires faking hard to mock classes and requires simulation to return your custom data for a particular LINQ statement. In this post, i will show how you can mock your LINQ repositories easily without much digging in. As,  i was goggling [my start page is bing, its a matter of time when i will be bing-ing :-)] around, found a nice post by Ronnie Holm, where he shows how to unit test a  LINQ to SQL repository. I will follow his trail and use some of the codes...
    July 20, 2010
  • .NET

    Fun with pointers in C#

    Disclaimer: this post is all about fun. It is not about: turning a bug into a feature; some new isolation/mocking practice; wow, look what I will do with pointers in my next project; It is all about fun :)
    July 19, 2010