code_junkie

Unit testing a method that calls another method

Nov 12th, 2011
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. modify(string value)
  2. {
  3. if(value.Length > 5) replaceit(value);
  4.  
  5. else changeit(value);
  6. }
  7.  
  8. public TestModifyIfValueLength..()
  9. {
  10. string expectedValue = .. ;// literal result of replaceit(value)
  11. Assert.Equals( expectedValue, modify("asd") );
  12. }
  13.  
  14. testLongValue() {
  15. string testValue = "A value longer than 5 chars";
  16. string expected = "Replaced!";
  17. string actual = modify(testValue);
  18. assertEqual(expected, actual);
  19. }
  20.  
  21. testShortValue() {
  22. string testValue = "len4";
  23. string expected = "Changed!";
  24. string actual = modify(testValue);
  25. assertEqual(expected, actual);
  26. }
Add Comment
Please, Sign In to add comment