??ò??????????????
???????????? ???????[ 2013/6/17 10:36:25 ] ????????
??????????????Щ????????????????????????????????????δ???????????????????к??????????????????????????????????????????????????????????????Щ?????д????ó??????????????????????????????????????????????????
????????????????ζ?????????
if (CARREFOUR.equals(supplier)) {
return EUR;
} else if (CENTURY_MART.equals(supplier)) {
return CNY;
} else {
throw new UnsupportedSupplierException(supplier);
}
?????????????????????????????????????????????????????????????????
@Test
public void returnsEurWhenGetCurrenyGivenCarrefour() throws Exception {
assertEquals(EUR?? target.getCurrencyBy(CARREFOUR));
}
@Test
public void returnsCnyWhenGetCurrenyGivenCenturyMart() throws Exception {
assertEquals(CNY?? target.getCurrencyBy(CENTURY_MART));
}
@Test(expected=UnsupportedSupplierException.class)
public void throwsExceptionWhenGetCurrenyGivenUnknownSupplier() throws Exception {
target.getCurrencyBy(WE_DONT_KNOW);
}
???????????????????μ???????????????????????????????????????????????????else if????????????????????????????????????????????????仯??????????????????£???????????ò???????????????????????????????????′???
final String currency = currencies.get(supplier);
if (currency != null) {
return currency;
} else {
throw new UnsupportedSupplierException(supplier);
}
?????????????Map???????????????????????????????????????
@Before
public void setupTestFixture() {
Map<string?? String> currencies = new HashMap<String?? String>();
currencies.put(MATCHED?? CORRESPONSED);
currencies.put(ANOTHER?? ANOTHER_CURRENCY);
target.setCurrencies(currencies);
}
@Test
public void returnsCorresponsedCurrencyWhenSupplierNameMatched() throws Exception {
assertEquals(CORRESPONSED?? target.getCurrencyBy(MATCHED));
}
@Test(expected=UnsupportedSupplierException.class)
public void throwsExceptionWhenGetCurrenyGivenUnknownSupplier() throws Exception {
target.getCurrencyBy(WE_DONT_KNOW);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11