Skip to content

feat: Lesson 15 Util Tests by Dwight Blue #498

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 2 commits 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
@@ -0,0 +1,69 @@
package com.codedifferently.lesson15;

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

import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class EmployeeManagerTest {

EmployeeManager manager;

@BeforeEach
void setUp() {
manager = new EmployeeManager();
Map<Integer, Employee> employee1 = new HashMap<>();
Employee employee = new Employee(1234, "Pierson", "Tech Support", 5.00);
}

@Test
public void testGetEmployee() {
// Given
Employee employee = new Employee(1234, "Pierson", "Tech Support", 5.00);
// When
manager.addEmployee(employee);

// Then
assertNotNull(employee.getId());
}

@Test
public void testUpdateEmployee() {
// Given
Employee employee = new Employee(1234, "Pierson", "Tech Support", 5.00);
// When
manager.addEmployee(employee);
manager.updateEmployee(employee);

// Then
assertEquals(1234, employee.getId());
}

@Test
public void testGetEmployeeCount() {
// Given
Employee employee1 = new Employee(1234, "Pierson", "Tech Support", 5.00);
Employee employee2 = new Employee(2345, "George", "President", 10);
// When
manager.addEmployee(employee1);
manager.addEmployee(employee2);

// Then
assertEquals(2, manager.getEmployeeCount());
}

@Test
public void testRemoveEmployee() {
// Given
Employee employee = new Employee(1234, "Pierson", "Tech Support", 5.00);
// When
manager.addEmployee(employee);
manager.removeEmployee(employee.getId());

// Then
assertEquals(1234, employee.getId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.codedifferently.lesson15;

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

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

public class EmployeeTest {

Employee employee;

@BeforeEach
void setUp() {
employee = new Employee(1234, "Pierson", "Tech Support", 5.00);
}

@Test
public void testGetId() {
// Given
// int expectedId = 1234;
employee.setId(1234);

// when
// Employee employee = new Employee(1234,"Pierson","Tech Support",5.00);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot have commented out code.


// Then
int actualId = employee.getId();
int expectedId = 1234;

assertEquals(expectedId, actualId);
}

@Test
public void testGetName() {
// Given
// String expectedName = "Pierson";
employee.setName("Pierson");

// when
// Employee employee = new Employee(1234,"Pierson","Tech Support",5.00);

// Then
String actualName = employee.getName();
String expectedName = "Pierson";

assertEquals(expectedName, actualName);
}

@Test
public void testGetDepartment() {
// Given
// String expectedDept = "Tech Support";
employee.setDepartment("Tech Support");

// when
// Employee employee = new Employee(1234,"Pierson","Tech Support",5.00);

// Then
String actualDept = employee.getDepartment();
String expectedDept = "Tech Support";

assertEquals(expectedDept, actualDept);
}

@Test
public void testGetSalary() {
// Given
// double expectedSalary = 5.00;
employee.setSalary(5.00);

// when
// Employee employee = new Employee(1234,"Pierson","Tech Support",5.00);

// Then
double actualSalary = employee.getSalary();
double expectedSalary = 5.00;

assertEquals(expectedSalary, actualSalary);
}
}
Loading