Quick glance at Moq
Last updated
Was this helpful?
Was this helpful?
[Test]
public void Ping_invokes_DoSomething()
{
// ARRANGE
var mock = new Mock<IFoo>();
mock.Setup(p => p.DoSomething(It.IsAny<string>())).Returns(true);
var sut = new Service(mock.Object);
// ACT
sut.Ping();
// ASSERT
mock.Verify(p => p.DoSomething("PING"), Times.Once());
}var mock = new Mock<IFoo>();mock.Setup(p => p.DoSomething(It.IsAny<string>())).Returns(true);var sut = new Service(mock.Object);sut.Ping();mock.Verify(p => p.DoSomething("PING"), Times.Once());