Skip to content

Commit 7847f94

Browse files
committed
chore: updated employeemanagertest
1 parent 5bda902 commit 7847f94

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lesson_15/tdd/tdd_app/src/main/java/com/codedifferently/lesson15/Employee.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ public double getSalary() {
4545
public void setSalary(double salary) {
4646
this.salary = salary;
4747
}
48+
49+
public boolean containsKey(Object id2) {
50+
// TODO Auto-generated method stub
51+
throw new UnsupportedOperationException("Unimplemented method 'containsKey'");
52+
}
4853
}

lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeManagerTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.codedifferently.lesson15;
22

3+
import static org.assertj.core.api.Assertions.*;
34
import static org.junit.jupiter.api.Assertions.*;
45

56
import org.junit.jupiter.api.BeforeEach;
67
import org.junit.jupiter.api.Test;
78

8-
class Lesson15Test {
9+
class EmployeeManagerTest {
910

1011
private EmployeeManager manager;
1112
private Employee emp;
@@ -49,4 +50,24 @@ public void testUpdateEmployee() {
4950
manager.getEmployee(1),
5051
"Updated employee details should match the new information.");
5152
}
53+
54+
@Test
55+
public void testRemoveEmployee() {
56+
// Arrange
57+
manager.addEmployee(emp);
58+
// Act
59+
manager.removeEmployee(1);
60+
Employee removedEmployee = manager.getEmployee(1);
61+
// Assert
62+
assertEquals(0, manager.getEmployeeCount(), "Employee count should be 0.");
63+
assertNull(removedEmployee, "Employee should be removed from system.");
64+
}
65+
66+
@Test
67+
public void testAssertEmployeeInCollection() throws Exception {
68+
// Act
69+
assertThatThrownBy(() -> manager.getEmployee(1))
70+
.isInstanceOf(IllegalArgumentException.class)
71+
.hasMessage("Employee does not in collection with id 1");
72+
}
5273
}

lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeTest.java

Whitespace-only changes.

0 commit comments

Comments
 (0)