Created
September 23, 2013 15:05
-
-
Save hartbit/6671807 to your computer and use it in GitHub Desktop.
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 SimpleTest() | |
{ | |
var calculator = Substitute.For<ICalculator>(); | |
int z; | |
calculator.Add(1, 2, out z).Returns(x => { x[2] = 2; return 3; }); | |
calculator.Add(4, 5, out z).Returns(x => { x[2] = 20; return 9; }); | |
Expect(calculator.Add(1, 2, out z), Is.EqualTo(3)); | |
Expect(z, Is.EqualTo(2)); | |
Expect(calculator.Add(4, 5, out z), Is.EqualTo(9)); // Expected 9 but was 0 | |
Expect(z, Is.EqualTo(20)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a known issue. Problem is that
Add(4,5,z)
is configured whenz=0
(its default value). Then during the test,Add(1,2,z)
setsz=2
, and the next call isAdd(4,5,out 2)
, which is not configured. If you addz=0;
to line 12 the test should pass.