Skip to content

Commit

Permalink
Update m4_03_testMortgageConstructorAndCorrectness
Browse files Browse the repository at this point in the history
  • Loading branch information
hhimanshu committed May 21, 2020
1 parent 1c6252f commit 40e4cb6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/test/java/com/h2/Module04_Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,16 @@ public void m4_03_testMortgageConstructorAndCorrectness() throws IllegalAccessEx
final Field[] fields = mortgageCalculator.getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
if (field.getName().equals("loanAmount")) {
assertEquals(loanAmount, (long) field.get(instance), "loanAmount should have value of " + loanAmount);
} else if (field.getName().equals("termInYears")) {
assertEquals(termInYears, (int) field.get(instance), "termInYears should have value of " + termInYears);
} else if (field.getName().equals("annualRate")) {
assertEquals(annualRate, (float) field.get(instance), "annualRate should have value of " + annualRate);
switch (field.getName()) {
case "loanAmount":
assertEquals(loanAmount, (long) field.get(instance), "loanAmount should have value of " + loanAmount);
break;
case "termInYears":
assertEquals(termInYears, (int) field.get(instance), "termInYears should have value of " + termInYears);
break;
case "annualRate":
assertEquals(annualRate, (float) field.get(instance), "annualRate should have value of " + annualRate);
break;
}
}

Expand Down

0 comments on commit 40e4cb6

Please sign in to comment.