Skip to content

Test Cases passed. #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<version>1.0-SNAPSHOT</version>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
28 changes: 28 additions & 0 deletions src/main/java/CurrencyConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.Map;
import java.util.TreeMap;

public class CurrencyConverter {

private double convertingCurrency;

private Map<String, Double> conversionMap = new TreeMap<String, Double>() {
{
put("Us Dollar", 1.00);
put("Euro", 0.94);
put("British Pound", 0.82);
put("Indian Rupee", 68.32);
put("Australian Dollar", 1.35);
put("Canadian Dollar", 1.32);
put("Singapore Dollar", 1.43);
put("Swiss Franc", 1.01);
put("Malaysian Ringgit", 4.47);
put("Japanese Yen", 115.84);
put("Chinese Yuan Renminbi", 6.92);
}
};
public double convertCurrentToDestinationCurrency(String current, String destination, double fatStack) {
convertingCurrency = ((conversionMap.get(destination)) / (conversionMap.get(current))) * fatStack;
return convertingCurrency;
}

}
Empty file removed src/main/java/DELETEME
Empty file.
104 changes: 104 additions & 0 deletions src/test/java/CurrencyConverterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.TreeMap;



public class CurrencyConverterTest {

CurrencyConverter converter;

@Before
public void Setup() {
converter = new CurrencyConverter();
}


@Test
public void testDollarToEuro() {
double expected = 1128.00;
double actual = converter.convertCurrentToDestinationCurrency(
"Us Dollar", "Euro", 1200);
Assert.assertEquals(expected, actual,.01 );
}

@Test
public void testEuroToDollar() {
double expected = 2180.85;
double actual = converter.convertCurrentToDestinationCurrency(
"Euro", "Us Dollar", 2050);
Assert.assertEquals(expected, actual,.01 );
}


@Test
public void testEuroToBritishPound() {
double expected = 283.51;
double actual = converter.convertCurrentToDestinationCurrency(
"Euro", "British Pound", 325);
Assert.assertEquals(expected, actual,.01 );
}


@Test
public void testBritishPoundToIndianRupee() {
double expected = 185797.07;
double actual = converter.convertCurrentToDestinationCurrency(
"British Pound", "Indian Rupee", 2230);
Assert.assertEquals(expected, actual,.01 );
}


@Test
public void testRupeeToCanadianDollar() {
double expected = 96.60;
double actual = converter.convertCurrentToDestinationCurrency(
"Indian Rupee", "Canadian Dollar", 5000);
Assert.assertEquals(expected, actual,.01 );
}


@Test
public void testCanadianDollarToSingaporeDollar() {
double expected = 59.58;
double actual = converter.convertCurrentToDestinationCurrency(
"Canadian Dollar", "Singapore Dollar", 55);
Assert.assertEquals(expected, actual,.01 );
}


@Test
public void testSingaporeDollarToSwissFranc() {
double expected = 234.49;
double actual = converter.convertCurrentToDestinationCurrency(
"Singapore Dollar", "Swiss Franc", 332);
Assert.assertEquals(expected, actual,.01 );
}


@Test
public void testSwissFrancToMalaysianRinggit() {
double expected = 5421.53;
double actual = converter.convertCurrentToDestinationCurrency(
"Swiss Franc", "Malaysian Ringgit", 1225);
Assert.assertEquals(expected, actual, .01);
}


@Test
public void testMalaysianRinggitToJapaneseYen() {
double expected = 8292.79;
double actual = converter.convertCurrentToDestinationCurrency(
"Malaysian Ringgit", "Japanese Yen", 320);
Assert.assertEquals(expected, actual,.01 );
}

@Test
public void testJapaneseYenToChineseYuanRenminbi() {
double expected = 7320.84;
double actual = converter.convertCurrentToDestinationCurrency(
"Japanese Yen", "Chinese Yuan Renminbi", 122550);
Assert.assertEquals(expected, actual,.01 );
}
}
Empty file removed src/test/java/DELETEME
Empty file.
Binary file added target/classes/CurrencyConverter$1.class
Binary file not shown.
Binary file added target/classes/CurrencyConverter.class
Binary file not shown.
Binary file added target/test-classes/CurrencyConverterTest.class
Binary file not shown.