- Replaced API

- Updated available currencies
 - Updated unit tests
 - Fix for failure handling
 - Android release signing
This commit is contained in:
2023-02-13 18:09:51 +00:00
parent 87d601a62c
commit afaa93fb41
14 changed files with 122 additions and 322 deletions

View File

@@ -25,6 +25,7 @@ import 'repository_test.mocks.dart';
onMissingStub: OnMissingStub.returnDefault),
MockSpec<http.HttpResponse<CurrencyResponse>>(
as: #MockCurrencyResponse, onMissingStub: OnMissingStub.returnDefault),
MockSpec<HttpException>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<DioError>(onMissingStub: OnMissingStub.returnDefault)
])
void main() {
@@ -85,7 +86,7 @@ void main() {
// When
when(currencyApi.getConversion("AUD", "GBP"))
.thenAnswer((_) async => Future.error(MockDioError()));
.thenAnswer((_) async => Future.error(MockHttpException()));
when(mockResponse.data).thenReturn(currencyResponse);
when(backupCurrencyApi.getCurrencyRate("AUD", "GBP"))
.thenAnswer((_) async => mockResponse);
@@ -98,17 +99,18 @@ void main() {
test('unable to retrieve rate from both APIs', () async {
// Given
DioError backUpError = MockDioError();
MockDioError backUpError = MockDioError();
// When
when(backUpError.error).thenReturn("Error message");
when(backUpError.message).thenReturn("Error message");
when(currencyApi.getConversion("AUD", "GBP"))
.thenAnswer((_) async => Future.error(MockDioError()));
when(backupCurrencyApi.getCurrencyRate("AUD", "GBP"))
.thenAnswer((_) async => Future.error(backUpError));
// Then
expect(() async =>
expect(
() async =>
await sut.getConversationRateFromApi(fromCurrency, toCurrency),
throwsA(predicate(
(e) => e is HttpException && e.message == 'Error message')));

View File

@@ -55,8 +55,8 @@ void main() {
// Then
String fromSelection = mainViewModel.getConversionPair(SelectionType.conversionFrom);
String toSelection = mainViewModel.getConversionPair(SelectionType.conversionTo);
expect(fromSelection, "ALL - Albanian Lek");
expect(toSelection, "ALL - Albanian Lek");
expect(fromSelection, "DZD - Algerian Dinar");
expect(toSelection, "DZD - Algerian Dinar");
});
test('set the currency rate from API', () async{