What is NDimple?

It's a .NET version of Dimple framework

Why I need NDimple?

You can use this framework to make stub when do unit testing. If you want to implement a huge interface, check this out. If you want to override one abstract method among a huge abstract class, check this out. If you want to start using mock framework to simulate behavior more complex than get set, check this out.

Is it easy?

public class StubDbCommand
{
public object ExecuteScalar()
{
return "Hello";
}
public static DbCommand New()
{
return NDimple.Implement<DbCommand>(new StubDbCommand());
}
}

Console.WriteLine(StubDbCommand.New().ExecuteScalar());

Output:

Hello

Protected Abstract Method?

public abstract class AbstractClass
{
protected abstract string AbstractMethod1();
protected abstract string AbstractMethod2();
public string InvokeAbstractMethod1()
{
return AbstractMethod1();
}
}

public abstract class StubAbstractClass : AbstractClass
{
protected override string AbstractMethod1()
{
return "Hello";
}
public static AbstractClass New()
{
return NDimple.Implement<AbstractClass>(typeof (StubAbstractClass));
}
}

Console.WriteLine(StubAbstractClass.New().InvokeAbstractMethod1());

Output:

Hello