Created
July 11, 2016 14:42
Back to Basics: Why Unit Testing is Hard 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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