-
Notifications
You must be signed in to change notification settings - Fork 25
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
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeManagerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
// 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); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.