Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static org.junit.Assert.*;
- import java.io.ByteArrayInputStream;
- import java.io.ByteArrayOutputStream;
- import java.io.InputStream;
- import java.io.PrintStream;
- import org.junit.Before;
- import org.junit.Ignore;
- import org.junit.Test;
- public class CompanyEmailSystemTest extends CompanyEmailSystem{
- private final ByteArrayOutputStream testOutputContent = new ByteArrayOutputStream();
- @Before
- public void setUpStreams() {
- System.setOut(new PrintStream(testOutputContent));
- }
- @Ignore
- //Bug Fix: incorrectly had an x as a parameter for getEmailsForPhase when it doesnt take a parameter
- //Written by Matthew and Richard
- public void testListPhases() {
- InputStream inputContent = new ByteArrayInputStream("2\rF".getBytes());
- System.setIn(inputContent);
- CompanyEmailSystem.main(null);
- String expectedContent = "What do you want to do?\n" +
- " P = List [P]rojects, [num] = Open Project [num], A = [A]dd Project, X = E[x]it\n" +
- "What do you want to do?\n" +
- " 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" +
- "1) Design - 3 Emails\n" +
- "2) Design - 3 Emails\n" +
- "What do you want to do?\n" +
- " 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";
- String receivedContent = testOutputContent.toString();
- expectedContent.replaceAll("\\s", "");
- receivedContent.replaceAll("\\s", "");
- assertEquals(expectedContent,receivedContent);
- }
- @Test
- //No Bug Fix
- //Written by Matthew and Richard
- public void testAddEmail() {
- InputStream inputContent = new ByteArrayInputStream("2\rA\rfrom@email.com\rto@email.com\rsubject\rmessage\rL".getBytes());
- System.setIn(inputContent);
- CompanyEmailSystem.main(null);
- String expectedContent = "What do you want to do?\n" +
- " P = List [P]rojects, [num] = Open Project [num], A = [A]dd Project, X = E[x]it\n" +
- "What do you want to do?\n" +
- " 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" +
- "Which email address is it from?\n" +
- "Which email address is it to?\n" +
- "What is the Subject?\n" +
- "What is the Message?\n" +
- "[Email added to Proj2 [Design]]\n" +
- "What do you want to do?\n" +
- " 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" +
- "Proj2 [Design]\n" +
- "\n" +
- " From Subject\n" +
- "--------------------------------\n" +
- "1) from@email.com - subject\n" +
- "2) me7@me.com - this is a test subject for email7\n" +
- "3) me4@me.com - this is a test subject for email4\n" +
- "4) me1@me.com - this is a test subject for email1\n" +
- "What do you want to do?\n" +
- " 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";
- String receivedContent = testOutputContent.toString();
- expectedContent.replaceAll("\\s", "");
- receivedContent.replaceAll("\\s", "");
- assertEquals(expectedContent,receivedContent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement