Advertisement
Guest User

George Mauer

a guest
Aug 19th, 2009
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using Xunit;
  3. using Rhino.Mocks;
  4.  
  5. namespace Sample.Tests {
  6.     // Extension Method
  7.     public interface ISomeInterface {
  8.         void SomeMethod(int param1);
  9.  
  10.     }
  11.     public static class Extensions {
  12.         public static ISomeInterface SomeMethod(this ISomeInterface someInterface, string someParam) {
  13.             // do work, then call the defined method in the interface
  14.             someInterface.SomeMethod(1);
  15.  
  16.             return someInterface;
  17.         }
  18.  
  19.     }
  20.  
  21.     public class Class1 {
  22.         // tried to do the following but it errors
  23.         [Fact]
  24.         public void SomeMethod_WithSomeInterface_CallsOtherSomeMethod() {
  25.             const string someParam = "something";
  26.             const int someOtherParam = 1;
  27.  
  28.             var mock = MockRepository.GenerateMock<ISomeInterface>();
  29.  
  30.             mock.SomeMethod(someParam);
  31.  
  32.             mock.AssertWasCalled(x => x.SomeMethod(someOtherParam));
  33.         }
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement