Skip to content

Commit

Permalink
Updated m3_04_testFieldsValueSetWhenConstructorCalled,m3_06_testSumOf…
Browse files Browse the repository at this point in the history
…CreditsWorksCorrectly,m3_08_testSumOfDebitsWorksCorrectly with constructor check
  • Loading branch information
hhimanshu committed May 21, 2020
1 parent 826d714 commit eba2eb2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/java/com/h2/Module3_Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public void m3_04_testFieldsValueSetWhenConstructorCalled() throws IllegalAccess
float[] credits = new float[]{10.0f, 20.0f};
float[] debits = new float[]{5.0f};
final Constructor<?> constructor = constructors[0];

int parameterCount = constructor.getParameterCount();
assertEquals(2, parameterCount, classToFind + " must have a constructor with 2 parameters - credits and debits, both should be of type 'float[]'");

Object instance = constructor.newInstance(credits, debits);

final Field[] fields = savingsCalculator.getDeclaredFields();
Expand Down Expand Up @@ -154,6 +158,10 @@ public void m3_06_testSumOfCreditsWorksCorrectly() throws IllegalAccessException
float[] credits = new float[]{10.0f, 20.0f};
float[] debits = new float[]{5.0f};
final Constructor<?> constructor = constructors[0];

int parameterCount = constructor.getParameterCount();
assertEquals(2, parameterCount, classToFind + " must have a constructor with 2 parameters - credits and debits, both should be of type 'float[]'");

Object instance = constructor.newInstance(credits, debits);

final String methodName = "sumOfCredits";
Expand Down Expand Up @@ -196,6 +204,10 @@ public void m3_08_testSumOfDebitsWorksCorrectly() throws IllegalAccessException,
float[] credits = new float[]{10.0f, 20.0f};
float[] debits = new float[]{5.0f, 10.f};
final Constructor<?> constructor = constructors[0];

int parameterCount = constructor.getParameterCount();
assertEquals(2, parameterCount, classToFind + " must have a constructor with 2 parameters - credits and debits, both should be of type 'float[]'");

Object instance = constructor.newInstance(credits, debits);

final String methodName = "sumOfDebits";
Expand Down

0 comments on commit eba2eb2

Please sign in to comment.