Created
July 11, 2016 14:47
-
-
Save simpleprogrammer-shared/77aaef90308a64d431672e2272c7057e to your computer and use it in GitHub Desktop.
Back to Basics: Why Unit Testing is Hard 6
This file contains hidden or 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 When3AddsThenGetHistory_ShouldReturnOnlyThose3Results() | |
{ | |
// Arrange | |
IStorageService storageServiceMock = Mocker.Mock <IStorageService>(); | |
storageServiceMock.Stub(service => service.IsServiceOnline()) | |
.Return(true); | |
storageServiceMock.Stub(service => service.GetHistorySession(1)) | |
.Return(new List <int>{4, 7, 9}); | |
var calculator = new Calculator(storageServiceMock); | |
calculator.Add(1, 3); | |
calculator.Add(2, 5); | |
calculator.Add(3, 6); | |
// Act | |
var result = calculator.GetHistory(); | |
// Assert | |
storageServiceMock.AssertWasCalled(service => | |
service.GetHistorySession(1); | |
Assert.Equal(4, result[0]); | |
Assert.Equal(7, resut[1]); | |
Assert.Equal(9, result[2]); | |
Assert.Equal(3, result.Count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment