Created
December 24, 2009 16:57
-
-
Save BenHall/263266 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace MockingCSharp | |
| { | |
| public class ImplementingMockableClass | |
| { | |
| IInterface mockedClass; | |
| public ImplementingMockableClass (IInterface mockable) | |
| { | |
| mockedClass = mockable; | |
| } | |
| public string OutputString() | |
| { | |
| return "This is the string: - " + mockedClass.GetString(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace MockingCSharp | |
| { | |
| public interface IInterface | |
| { | |
| string GetString(); | |
| } | |
| public class ClassWithInterface : IInterface | |
| { | |
| public string GetString() | |
| { | |
| return "ClassWithInterface - Mockable"; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'mocking_csharp.dll' | |
| include MockingCSharp | |
| $: << 'C:/IronRuby/lib/IronRuby/gems/1.8/gems/caricature-0.7.2/lib' | |
| require 'caricature' | |
| include Caricature | |
| i = ImplementingMockableClass.new(ClassWithInterface.new) | |
| puts i.OutputString() | |
| isolation = Isolation.for(IInterface) | |
| isolation.when_receiving(:get_string) do |exp| | |
| exp.return('MOCKED!!') | |
| end | |
| i = ImplementingMockableClass.new(isolation) | |
| puts i.OutputString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This is the string: - ClassWithInterface - Mockable | |
| This is the string: - MOCKED!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment