Fakultas Ilmu Komputer UI

Commit 9d731346 authored by hazlazuardi's avatar hazlazuardi
Browse files

Merge with altaaj for assignmentListTest

parents 963409cb 7ea856a7
Pipeline #81979 passed with stages
in 4 minutes and 54 seconds
package repository;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.repository.AssignmentList;
import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.model.Assignment;
import org.checkerframework.checker.units.qual.A;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
import java.lang.System;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class AssignmentListTest {
private static final AssignmentList assignmentList = new AssignmentList();
private final PrintStream standardOut = System.out;
private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
private Assignment assignment;
@BeforeEach
void setup() {
assignment = new Assignment();
assignment.setAssignmentName("name");
}
@Test
void getAssignmentList(){
assignmentList.addAssignment("name", assignment);
List<Assignment> TestList = assignmentList.getAssignmentList();
assertNotEquals(null, TestList);
}
@Test
void addAssignmentTest(){
int before = assignmentList.getAssignmentList().size();
assignmentList.addAssignment("name", assignment);
int after = assignmentList.getAssignmentList().size();
assertEquals(before + 1, after);
}
@Test
void deleteAssignmentTest(){
assignmentList.addAssignment("name", assignment);
int before = assignmentList.getAssignmentList().size();
assignmentList.deleteAssignment(assignment);
int after = assignmentList.getAssignmentList().size();
assertEquals(before - 1, after);
}
@Test
void ListToStringTest(){
System.setOut(new PrintStream(outputStreamCaptor));
assignmentList.addAssignment("name", assignment);
assignmentList.listToString(assignmentList.getAssignmentList());
assertEquals("1" + ". " + "name" +"\n" +
"\s valid: " + "false", outputStreamCaptor.toString().trim());
System.setOut(standardOut);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment