-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Changed nameing to be clear and fit conventions and provided mor…
… consise tests
- Loading branch information
Mohamed
committed
Mar 14, 2024
1 parent
8564356
commit b48d11e
Showing
8 changed files
with
83 additions
and
145 deletions.
There are no files selected for viewing
12 changes: 7 additions & 5 deletions
12
...bjects/objects_app/src/main/java/com/codedifferently/lesson7/MohamedObjects/Main/CPU.java
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
...pp/src/main/java/com/codedifferently/lesson7/MohamedObjects/Main/IllegalYearExeption.java
This file contains 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
49 changes: 0 additions & 49 deletions
49
...ects/objects_app/src/main/java/com/codedifferently/lesson7/MohamedObjects/Main/Parts.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
.../objects_app/src/main/java/com/codedifferently/lesson7/MohamedObjects/Main/cpuBrands.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
.../objects_app/src/main/java/com/codedifferently/lesson7/MohamedObjects/Main/portTypes.java
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
lesson_07/objects/objects_app/src/test/java/com/codedifferently/lesson7/MohamedTest.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
..._app/src/test/java/com/codedifferently/lesson7/mohamedobjects/main/ComputerPartsTest.java
This file contains 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,65 @@ | ||
package com.codedifferently.lesson7.mohamedobjects.main; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import java.util.Set; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ComputerPartsTest { | ||
CPU cpu = new CPU("M1", 2020, cpuBrand.INTEL, 23.32); | ||
GPU bGpu = new GPU("Radion 560 xt", 2015, "AMD", 8); | ||
Part apart = new Part(); | ||
|
||
@Test | ||
public void testCpuConstruction() { | ||
assertEquals(23.32, cpu.getClockSpeed()); | ||
|
||
assertNotEquals(8, cpu.getCores()); | ||
|
||
cpu.setCores(8); | ||
|
||
assertEquals(8, cpu.getCores()); | ||
|
||
assertEquals(2020, cpu.getReleaseYear()); | ||
|
||
assertNotEquals("M2", cpu.getName()); | ||
} | ||
|
||
@Test | ||
void testGpuConstruction() { | ||
|
||
Set<portType> porty = Set.of(portType.DP, portType.HDMI, portType.VGA); | ||
bGpu.addPorts(portType.DP); | ||
bGpu.addPorts(portType.HDMI); | ||
bGpu.addPorts(portType.VGA); | ||
assertEquals(porty, bGpu.getPorts()); | ||
|
||
assertEquals(3, bGpu.calculateNumPorts()); | ||
} | ||
|
||
@Test | ||
void testYearValadation() { | ||
assertThrows( | ||
IllegalYearExeption.class, | ||
() -> { | ||
bGpu.checkValidYear(1999); | ||
}); | ||
assertThrows( | ||
IllegalYearExeption.class, | ||
() -> { | ||
bGpu.checkValidYear(3000); | ||
}); | ||
} | ||
|
||
@Test | ||
void testPartConstruction() { | ||
apart.setBrand("A Brand"); | ||
apart.setName("A Part"); | ||
apart.setReleaseYear(2011); | ||
assertEquals("A Brand", apart.getBrand()); | ||
assertEquals("A Part", apart.getName()); | ||
assertEquals(2011, apart.getReleaseYear()); | ||
} | ||
} |