public void test_should_handle_runtime_error_properly() { // given givenExceptionWhileRequestingWebService(); // when ExchangeRate downloadedRate = downloadRate("USD", "SGD"); // then assertFalse(downloadedRate.isOk()); assertRate(downloadedRate, "USD", "SGD"); assertEquals("Unable to get exchange rates: Timeout", downloadedRate.getErrorMessage()); }
public void test_should_handle_error_from_webservice_properly() { // given givenResponseFromWebService( anyUrl(), "System.IO.IOException: There is not enough space on the disk.\r\nStacktrace..."); // when ExchangeRate downloadedRate = downloadRate("USD", "SGD"); // then assertFalse(downloadedRate.isOk()); assertEquals( "Something wrong with the exchange rates provider. Response from the service - System.IO.IOException: There is not enough space on the disk.", downloadedRate.getErrorMessage()); }