/BillCalcTest.java Secret
Created
August 16, 2016 03:26
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
package com.telco.billing; | |
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
public class BillCalcTest { | |
@Test | |
public void calculate_bill_for_lite_package_when_the_limit_is_not_exceeded() { | |
float excessAmount = 0; | |
BillCalc billCalc = new BillCalc(); | |
float actualBill = billCalc.calc(BillCalc.LITE_PACKAGE, excessAmount); | |
float expectedAmount = 550.0f; // 500 + 500 * 0.1 | |
float delta = 0; | |
assertEquals(expectedAmount, actualBill, delta); | |
} | |
@Test | |
public void calculate_bill_for_lite_package_when_the_limit_is_exceeded() { | |
float excessAmount = 1; | |
BillCalc billCalc = new BillCalc(); | |
float actualBill = billCalc.calc(BillCalc.LITE_PACKAGE, excessAmount); | |
float expectedAmount = 825.0f; // ( 500 + 250 ) + (500 + 250) * 0.1 | |
float delta = 0; | |
assertEquals(expectedAmount, actualBill, delta); | |
} | |
@Test | |
public void calculate_bill_for_mega_package_when_the_limit_is_not_exceeded() { | |
float excessAmount = 0; | |
BillCalc billCalc = new BillCalc(); | |
float actualBill = billCalc.calc(BillCalc.MEGA_PACKAGE, excessAmount); | |
float expectedAmount = 825.0f; // 750 + 750 * 0.1 | |
float delta = 0; | |
assertEquals(expectedAmount, actualBill, delta); | |
} | |
@Test | |
public void calculate_bill_for_mega_package_when_the_limit_is_exceeded() { | |
float excessAmount = 1; | |
BillCalc billCalc = new BillCalc(); | |
float actualBill = billCalc.calc(BillCalc.MEGA_PACKAGE, excessAmount); | |
float expectedAmount = 1100.0f; // ( 750 + 250 ) + (750 + 250) * 0.1 | |
float delta = 0; | |
assertEquals(expectedAmount, actualBill, delta); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment