public void CreateDelegateMockTest() { var mock = new Mock<Func<int, string>>(); mock.ExpectCall(m => m(2)).Returns("2").Once(); var value = mock.Object(2); mock.Verify(); Assert.That(value, Is.EqualTo("2")); }
public void CreateInterfaceMockTest() { var mock = new Mock<IMocked>(); mock.ExpectCall(m => m.Method(2)).Returns("2").Once(); mock.ExpectGet(m => m.Property).Gets(2).Never(); mock.ExpectSet(m => m.Property).Sets(2).Never(); var value = mock.Object.Method(2); mock.Verify(); Assert.That(value, Is.EqualTo("2")); }