daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using Moq;
  3. using NUnit.Framework;
  4.  
  5. namespace StackOverflow
  6. {
  7.     [TestFixture]
  8.     class Tester
  9.     {
  10.         [Test]
  11.         public void Test()
  12.         {
  13.             var mock = new Mock<IMockable>();
  14.             var tc = new TestClass();
  15.            
  16.             tc.DoSomething(mock.Object);
  17.  
  18.             mock.Verify(v => v.DoMockSomething(new MockHelper(null, @"Forward")));
  19.         }
  20.     }
  21.  
  22.     public class TestClass
  23.     {
  24.         public void DoSomething(IMockable mockable)
  25.         {
  26.             mockable.DoMockSomething(new MockHelper(null, @"Forward"));
  27.         }
  28.     }
  29.  
  30.     public class MockHelper : IEquatable<MockHelper>
  31.     {
  32.         public MockHelper(object obj, string strang) { }
  33.         public bool Equals(MockHelper other)
  34.         {
  35.             return true;
  36.         }
  37.  
  38.         public override bool Equals(object obj)
  39.         {
  40.             return Equals(obj as MockHelper);
  41.         }
  42.  
  43.         public override int GetHashCode()
  44.         {
  45.             return base.GetHashCode();
  46.         }
  47.  
  48.     }
  49.  
  50.     public interface IMockable
  51.     {
  52.         void DoMockSomething(MockHelper helper);
  53.     }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top