• .NET

    Fakes, Stubs, and Mocks

    In Doing Your First Mock, Mehfuz Hossain explained why you should use mocking to improve your unit tests and then used a real world example to demonstrate this technique. In this post, I will take you down a different path using other forms of stand-ins.
  • .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...
    August 03, 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

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

    [Want to see JustMock in action? Register for the free webinar this Thursday, Jul 22, 11 am EST and check out What’s New in JustCode, JustMock, and OpenAccess ORM. During the live event attendees will also have the chance to win a Telerik Ultimate Collection (valued at $1999).]   In JustMock. The tale continues... (Part 1) we saw how we can inject prologue/epilogue code in .NET methods with JustMock. We covered the most simplest scenarios and some more complex ones as methods with ref/out parameters. Today I will show you how to do code injections in generic methods. Basically there is nothing new. We are already familiar with: AtStartOfAction AtStartOfFunc AtEndOfAction AtEndOfFunc etc. and last time...
  • .NET

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

    Last time we talked about how to inject code at the beginning of a method. Today I will post how to inject code at the end of a method and I will cover some more complex scenarios as well. So lets start with sample program and then I will explain it in details. using System; using Telerik.CodeWeaver.Hook;   namespace ConsoleApplication2 {     sealed class MyClass     {         public void SayHello() { Console.WriteLine("Hello!"); }           public int SayHello(string name)         {             Console.WriteLine("Hello {0}!", LastName = name);             return (name ?? string.Empty).Length;         }           public string LastName { get; set; }           public int Increment10(ref int...