public void DoSomething_increments_counter() { var counter = new Counter(); var subject = new ClassThatIncrementsCounter(counter); subject.DoSomething(); Assert.AreEqual(1, counter.Value); }
public void DoSomething_increments_counter() { var counter = new Mock<ICounter>(); // indicate that we want to track whether this method was called. counter.Setup(x => x.Increment()).Verifiable(); var subject = new ClassThatIncrementsCounter(counter.Object); subject.DoSomething(); // verify that the method was called. counter.Verify(x => x.Increment()); }