Commit b56d27a97708b9160c2f3dbbe9a475db49271813

Authored by Iuliia Romanivna Ukrainets
1 parent 70549e6e

add unit tests

app/src/main/java/com/example/loancalculator/Operation.java
... ... @@ -68,4 +68,14 @@ public class Operation {
68 68 return list;
69 69  
70 70 }
  71 +
  72 + @Override
  73 + public String toString() {
  74 + return "Operation{" +
  75 + "principal=" + principal +
  76 + ", interest=" + interest +
  77 + ", payment=" + payment +
  78 + ", balance=" + balance +
  79 + '}';
  80 + }
71 81 }
... ...
app/src/test/java/com/example/loancalculator/ExampleUnitTest.java renamed to app/src/test/java/com/example/loancalculator/CalculatorUnitTest.java
... ... @@ -2,6 +2,8 @@ package com.example.loancalculator;
2 2  
3 3 import org.junit.Test;
4 4  
  5 +import java.util.List;
  6 +
5 7 import static org.junit.Assert.*;
6 8  
7 9 /**
... ... @@ -9,9 +11,26 @@ import static org.junit.Assert.*;
9 11 *
10 12 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11 13 */
12   -public class ExampleUnitTest {
  14 +public class CalculatorUnitTest {
  15 + //test input;
  16 +
  17 + @Test
  18 + public void anuityLoanIsCorrect() {
  19 + float expectedBalance = 0;
  20 + List<Operation> result = Operation.calculateAnuity(50000,0.5f,2);
  21 + assertEquals(expectedBalance, result.get(result.size()-1).getBalance(),0.1f);
  22 + }
  23 +
  24 + @Test
  25 + public void anuityLoanIsCorrectCount() {
  26 + long expectedResult = 2;
  27 + List<Operation> result = Operation.calculateAnuity(50000,0.5f,2);
  28 + assertEquals(expectedResult, result.size());
  29 + }
  30 +
13 31 @Test
14   - public void addition_isCorrect() {
  32 + public void serialLoanIsCorrect() {
  33 + //TODO
15 34 assertEquals(4, 2 + 2);
16 35 }
17 36 }
18 37 \ No newline at end of file
... ...