TddKata1
Uploader Comments (fredericALTorres)
All Comments (6)
-
@fredericALTorres Agree with RapaFan. You have to first test that Add("1") returns 1, which you hardcode in as a least effort solution. Then you will have to add a test that calls Add("2") which is another single number test case. After that test failes you convert the hardcoded "return 1" with "return int.Parse(numbers)".
-
@fredericALTorres Rapa is right. If you would have done a test with input "2" after your test with input "1" it would have failed. In other words, you never verified that your calculator would work with any one number input besides "1".
When I did it, I refactored to if String.IsNullOrEmpty return 0, otherwise, return the int value of the string so I didn't test the input of "2", but the way you did it makes me wonder if I should've tested that. I still think not, but an interesting thought.
-
@fredericALTorres Yeah I noticed You removed it in the end. But that would be my next test. Calc.Add("1") then Calc.Add("2"). How You did it made this line last very long but You knew from the beggining that it will be removed later. Why not do it in next test?
I started with the test case Calc.Add("1")
and then I went for Calc.Add("1,2").
I did not test Calc.Add("1")
fredericALTorres 10 months ago
You made a mistake. You created if numbers="1" return 1 and then You did different test and left the code. You should add test with "2" string next.
RapaFan 10 months ago
@RapaFan Can you give me more info, The line of code if numbers="1" return 1;
will be removed at some point
fredericALTorres 10 months ago