public void Does_ExerciseInterface_Call_DoSomething() { //arrange var mock = new Mock <IDemoOne>(); mock.Setup(x => x.DoSomething(It.IsAny <bool>())) .Returns <bool>(b => b ? 1 : 0); var demo = new DemoClass(mock.Object); //act Assert.AreEqual(1, demo.ExerciseInterface()); //assert mock.Verify(x => x.DoSomething(true), Times.Once()); mock.Verify(x => x.DoSomething(false), Times.Never()); }
public void Does_ExerciseInterface_Call_DoSomething() { //arrange var mock = new Mock<IDemoOne>(); mock.Setup(x => x.DoSomething(It.IsAny<bool>())) .Returns<bool>(b => b ? 1 : 0); var demo = new DemoClass(mock.Object); //act Assert.AreEqual(1, demo.ExerciseInterface()); //assert mock.Verify(x => x.DoSomething(true), Times.Once()); mock.Verify(x => x.DoSomething(false), Times.Never()); }