Advertisement
Guest User

Untitled

a guest
May 4th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. import static org.junit.Assert.*;
  2.  
  3. import java.io.ByteArrayInputStream;
  4. import java.io.ByteArrayOutputStream;
  5. import java.io.InputStream;
  6. import java.io.PrintStream;
  7.  
  8. import org.junit.Before;
  9. import org.junit.Ignore;
  10. import org.junit.Test;
  11.  
  12. public class CompanyEmailSystemTest extends CompanyEmailSystem{
  13.  
  14. private final ByteArrayOutputStream testOutputContent = new ByteArrayOutputStream();
  15.  
  16. @Before
  17. public void setUpStreams() {
  18. System.setOut(new PrintStream(testOutputContent));
  19.  
  20. }
  21.  
  22. @Ignore
  23. //Bug Fix: incorrectly had an x as a parameter for getEmailsForPhase when it doesnt take a parameter
  24. //Written by Matthew and Richard
  25. public void testListPhases() {
  26. InputStream inputContent = new ByteArrayInputStream("2\rF".getBytes());
  27. System.setIn(inputContent);
  28.  
  29. CompanyEmailSystem.main(null);
  30.  
  31. String expectedContent = "What do you want to do?\n" +
  32. " P = List [P]rojects, [num] = Open Project [num], A = [A]dd Project, X = E[x]it\n" +
  33. "What do you want to do?\n" +
  34. " L = [L]ist Emails, A = [A]dd Email, F = List Phase [F]olders, N = Move to [N]ext Phase, [num] = List Emails in Phase [num], C = List [C]ontacts, X = E[x]it Project\n" +
  35. "1) Design - 3 Emails\n" +
  36. "2) Design - 3 Emails\n" +
  37. "What do you want to do?\n" +
  38. " L = [L]ist Emails, A = [A]dd Email, F = List Phase [F]olders, N = Move to [N]ext Phase, [num] = List Emails in Phase [num], C = List [C]ontacts, X = E[x]it Project\n";
  39.  
  40. String receivedContent = testOutputContent.toString();
  41. expectedContent.replaceAll("\\s", "");
  42. receivedContent.replaceAll("\\s", "");
  43.  
  44. assertEquals(expectedContent,receivedContent);
  45. }
  46.  
  47. @Test
  48. //No Bug Fix
  49. //Written by Matthew and Richard
  50. public void testAddEmail() {
  51. InputStream inputContent = new ByteArrayInputStream("2\rA\rfrom@email.com\rto@email.com\rsubject\rmessage\rL".getBytes());
  52. System.setIn(inputContent);
  53.  
  54. CompanyEmailSystem.main(null);
  55.  
  56. String expectedContent = "What do you want to do?\n" +
  57. " P = List [P]rojects, [num] = Open Project [num], A = [A]dd Project, X = E[x]it\n" +
  58.  
  59. "What do you want to do?\n" +
  60. " L = [L]ist Emails, A = [A]dd Email, F = List Phase [F]olders, N = Move to [N]ext Phase, [num] = List Emails in Phase [num], C = List [C]ontacts, X = E[x]it Project\n" +
  61.  
  62. "Which email address is it from?\n" +
  63.  
  64. "Which email address is it to?\n" +
  65.  
  66. "What is the Subject?\n" +
  67.  
  68. "What is the Message?\n" +
  69.  
  70. "[Email added to Proj2 [Design]]\n" +
  71. "What do you want to do?\n" +
  72. " L = [L]ist Emails, A = [A]dd Email, F = List Phase [F]olders, N = Move to [N]ext Phase, [num] = List Emails in Phase [num], C = List [C]ontacts, X = E[x]it Project\n" +
  73.  
  74. "Proj2 [Design]\n" +
  75. "\n" +
  76. " From Subject\n" +
  77. "--------------------------------\n" +
  78. "1) from@email.com - subject\n" +
  79. "2) me7@me.com - this is a test subject for email7\n" +
  80. "3) me4@me.com - this is a test subject for email4\n" +
  81. "4) me1@me.com - this is a test subject for email1\n" +
  82. "What do you want to do?\n" +
  83. " L = [L]ist Emails, A = [A]dd Email, F = List Phase [F]olders, N = Move to [N]ext Phase, [num] = List Emails in Phase [num], C = List [C]ontacts, X = E[x]it Project\n";
  84.  
  85. String receivedContent = testOutputContent.toString();
  86. expectedContent.replaceAll("\\s", "");
  87. receivedContent.replaceAll("\\s", "");
  88.  
  89. assertEquals(expectedContent,receivedContent);
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement