code_junkie

Best practices of unittesting methods that contain conditional conditions

Nov 13th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public void ExportAccounts()
  2. {
  3. int emptyAccounts = 0;
  4. int nonEmptyAccounts = 0;
  5. int errorous = 0;
  6. string outputPath = this.GetOutputPath();
  7. Account[] accounts = this.MyWebserviceAdapter.GetAccounts();
  8. foreach(Account account in accounts)
  9. {
  10. try
  11. {
  12. if(account.Amount > 0)
  13. {
  14. this.ExportNonEmpty(outputPath, account);
  15. nonEmptyAccounts++;
  16. } else {
  17. this.ExportEmptyAccount(outputPath, account);
  18. emptyAccounts++;
  19. }
  20. } catch(Exception e) {
  21. logger.error(e);
  22. errorous++;
  23. }
  24. }
  25. logger.debug(string.Format("{0} empty / {1} non empty / {2} errorous", emptyAccounts, nonEmptyAccounts, errorous));
  26. }
Add Comment
Please, Sign In to add comment