@@ -14,6 +14,134 @@ public void testLesson15() {
1414 @ Test
1515 public void testGetGreeting () {
1616 // Act
17- Lesson15 .main (null );
17+ String greeting = new Lesson15 ().getGreeting ("World" );
18+ // Assert
19+ assertThat (greeting ).isEqualTo ("Hello, World!" );
20+ }
21+
22+ @ Test
23+ public void employeeManagerTest () {
24+ // Arrange
25+ EmployeeManager employeeManager = new EmployeeManager ();
26+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
27+ // Act
28+ employeeManager .addEmployee (employee );
29+ // Assert
30+ assertThat (employeeManager .getEmployeeCount ()).isEqualTo (1 );
31+ }
32+
33+ @ Test
34+ public void testAddEmployee () {
35+ // Arrange
36+ EmployeeManager employeeManager = new EmployeeManager ();
37+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
38+ // Act
39+ employeeManager .addEmployee (employee );
40+ // Assert
41+ assertThat (employeeManager .getEmployeeCount ()).isEqualTo (1 );
42+ }
43+
44+ @ Test
45+ public void testGetEmployee () {
46+ // Arrange
47+ EmployeeManager employeeManager = new EmployeeManager ();
48+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
49+ employeeManager .addEmployee (employee );
50+ // Act
51+ Employee retrievedEmployee = employeeManager .getEmployee (1 );
52+ // Assert
53+ assertThat (retrievedEmployee ).isEqualTo (employee );
54+ }
55+
56+ @ Test
57+ public void testRemoveEmployee () {
58+ // Arrange
59+ EmployeeManager employeeManager = new EmployeeManager ();
60+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
61+ employeeManager .addEmployee (employee );
62+ // Act
63+ employeeManager .removeEmployee (1 );
64+ // Assert
65+ assertThat (employeeManager .getEmployeeCount ()).isEqualTo (0 );
66+ }
67+
68+ @ Test
69+ public void testGetid () {
70+ // Arrange
71+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
72+ // Act
73+ int id = employee .getId ();
74+ // Assert
75+ assertThat (id ).isEqualTo (1 );
76+ }
77+
78+ @ Test
79+ public void testSetId () {
80+ // Arrange
81+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
82+ // Act
83+ employee .setId (2 );
84+ // Assert
85+ assertThat (employee .getId ()).isEqualTo (2 );
86+ }
87+
88+ @ Test
89+ public void testGetName () {
90+ // Arrange
91+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
92+ // Act
93+ String name = employee .getName ();
94+ // Assert
95+ assertThat (name ).isEqualTo ("Ezra Nyabuti" );
96+ }
97+
98+ @ Test
99+ public void testSetName () {
100+ // Arrange
101+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
102+ // Act
103+ employee .setName ("Ezra Nyabuti" );
104+ // Assert
105+ assertThat (employee .getName ()).isEqualTo ("Ezra Nyabuti" );
106+ }
107+
108+ @ Test
109+ public void testGetDepartment () {
110+ // Arrange
111+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
112+ // Act
113+ String department = employee .getDepartment ();
114+ // Assert
115+ assertThat (department ).isEqualTo ("Software Engineer" );
116+ }
117+
118+ @ Test
119+ public void testSetDepartment () {
120+ // Arrange
121+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 0 );
122+ // Act
123+ employee .setDepartment ("Data Scientist" );
124+ // Assert
125+ assertThat (employee .getDepartment ()).isEqualTo ("Data Scientist" );
126+ }
127+
128+ @ Test
129+ public void testGetSalary () {
130+ // Arrange
131+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 100000 );
132+ // Act
133+ double salary = employee .getSalary ();
134+ // Assert
135+ assertThat (salary ).isEqualTo (100000 );
136+ }
137+
138+ @ Test
139+ public void testSetSalary () {
140+ // Arrange
141+ Employee employee = new Employee (1 , "Ezra Nyabuti" , "Software Engineer" , 100000 );
142+ // Act
143+ employee .setSalary (120000 );
144+ // Assert
145+ assertThat (employee .getSalary ()).isEqualTo (120000 );
18146 }
19147}
0 commit comments