Skip to content

Instantly share code, notes, and snippets.

@kdkanishka
Created August 16, 2016 03:26
Show Gist options
  • Save kdkanishka/d47a5feb75bcb52ecaef43f7907b9160 to your computer and use it in GitHub Desktop.
Save kdkanishka/d47a5feb75bcb52ecaef43f7907b9160 to your computer and use it in GitHub Desktop.
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