Unittests mit Mockito
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
919 B

3 years ago
  1. package de.edu.hsfulda.ciip.tdd;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.PrintStream;
  5. import java.util.List;
  6. public class TannenbaumUi {
  7. public static final String TREE_SIZE_PROMPT = "enter tree size:";
  8. private InputStream input;
  9. private PrintStream output;
  10. public TannenbaumUi(InputStream input, PrintStream output) {
  11. this.input = input;
  12. this.output = output;
  13. // TODO Auto-generated constructor stub
  14. }
  15. public int getTreeSize() {
  16. output.println("enter tree size:");
  17. try {
  18. int available = input.available();
  19. int treesize = 0;
  20. for (int i = 0; i < available; i++) {
  21. treesize *= 10;
  22. treesize += input.read() - '0';
  23. }
  24. return treesize;
  25. } catch (IOException e) {
  26. e.printStackTrace();
  27. throw new RuntimeException(e);
  28. }
  29. }
  30. public void print(List<String> messageLines) {
  31. for (String line : messageLines) {
  32. output.println(line);
  33. }
  34. }
  35. }