-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace global reference with getter to control singleton.
- Loading branch information
Showing
2 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
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
24 changes: 18 additions & 6 deletions
24
Java/src/test/java/org/codecop/dependencies/d/ShippingCostTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
package org.codecop.dependencies.d; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import org.junit.Test; | ||
|
||
public class ShippingCostTest { | ||
|
||
@Test | ||
public void test4() { | ||
ShippingCost shippingCost = new ShippingCost(); | ||
|
||
assertNotNull(shippingCost); | ||
public void inEuropeanMarket() { | ||
RestCountriesAPI restCountriesAPI = mock(RestCountriesAPI.class); | ||
when(restCountriesAPI.isInCommonMarket(new Country("AT"))).thenReturn(true); | ||
ShippingCost shippingCost = new ShippingCost() { | ||
@Override | ||
protected RestCountriesAPI getRestCountriesInstance() { | ||
return restCountriesAPI; | ||
} | ||
}; | ||
|
||
Money cost = shippingCost.calculate(new Country("AT"), DeliveryOptions.STANDARD); | ||
|
||
assertEquals(new Money(5), cost); | ||
// 3 seconds :-( | ||
} | ||
} |