Skip to content

Feat: Adds Shawn Dunsmore Jr Implemented Tests. #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public double getSalary() {
public void setSalary(double salary) {
this.salary = salary;
}

public String getDetails(){
return "ID: " + id + ", Name: " + name + ", Department: " + department + ", Salary: " + salary;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codedifferently.lesson15;

import static org.assertj.core.api.Assertions.assertThat;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

class Lesson15Test {
Expand All @@ -16,4 +16,67 @@ public void testGetGreeting() {
// Act
Lesson15.main(null);
}

@Test
public void testEmployeeId_Exists(){
Employee employee = new Employee(0, null, null, 0);
assertEquals(0, employee.getId());
}

@Test
public void testEmployeeName_Exists(){
Employee employee = new Employee(0, "dave", null, 0);
assertEquals("dave", employee.getName());
}
@Test
public void testEmployeeDepartment_Exists(){
Employee employee = new Employee(0, "dave", "IT", 0);
assertEquals("IT", employee.getDepartment());
}
@Test
public void testEmployeeSalary_Exists(){
Employee employee = new Employee(0, "dave", "IT", 10000);
assertEquals(10000, employee.getSalary());
}
@Test
public void testGetEmployee(){
Employee employee = new Employee(10, null, null, 0);
EmployeeManager manager = new EmployeeManager();
manager.addEmployee(employee);
assertEquals(employee, manager.getEmployee(10));
}
@Test
public void testGetEmployeeCount(){
Employee employee = new Employee(10, null, null, 0);
EmployeeManager manager = new EmployeeManager();
manager.addEmployee(employee);
assertEquals(1, manager.getEmployeeCount());
}
@Test
public void testGetEmployeeUpate(){
Employee employee2 = new Employee(10, "BillyBobJenkins", null, 0);
Employee employee = new Employee(10, "Dave", null, 0);
EmployeeManager manager = new EmployeeManager();
manager.addEmployee(employee);
manager.updateEmployee(employee2);

assertEquals(employee2, manager.getEmployee(10));
}
@Test
public void testGetEmployeeRemove(){
Employee employee2 = new Employee(10, "BillyBobJenkins", null, 0);
Employee employee = new Employee(11, "Dave", null, 0);
EmployeeManager manager = new EmployeeManager();
manager.addEmployee(employee);
manager.addEmployee(employee2);
manager.removeEmployee(10);

assertEquals(1, manager.getEmployeeCount());
}
@Test
public void testGetDetails(){
Employee employee2 = new Employee(10, "BillyBobJenkins", "IT", 10);
assertEquals("ID: 10, Name: BillyBobJenkins, Department: IT, Salary: 10.0", employee2.getDetails());

}
}
Loading