Skip to content

Instantly share code, notes, and snippets.

Back to Basics: Why Unit Testing is Hard 3
[Test]
public void WhenAdding2NumbersAndServiceOnline_SumIsReturnedAndStored()
{
// Arrange
IStorageService storageServiceMock = Mocker.Mock <IStorageService>();
storageServiceMock.Stub(service => service.IsServiceOnline())
.Return(true);
var calculator = new Calculator(storageServiceMock);
// Act
var result = calculator.Add(3, 4);
// Assert
storageServiceMock.AssertWasCalled(service => service.Store(7);
Assert.Equals(7, result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment