示例#1
0
 public void DoSomething_increments_counter()
 {
     var counter = new Counter();
     var subject = new ClassThatIncrementsCounter(counter);
     subject.DoSomething();
     Assert.AreEqual(1, counter.Value);
 }
示例#2
0
 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());
 }