Created
September 8, 2021 11:56
-
-
Save PreyeaRegmi/e02ac591b9124fa538d27c2ece8ee60c to your computer and use it in GitHub Desktop.
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
test( | |
"Fetch loan should not fail with any exception when mocked with success response", | |
() { | |
FetchLoanDetail fetchLoanUseCase = | |
FetchLoanDetail(MockedSucessRateFetchRepository(LoanDetailDTO(3))); | |
fetchLoanUseCase.execute(LoanParamRequest(100, 2), (data) {}, | |
expectAsync1((error) { | |
expect(error, isNot(isInstanceOf<UseCaseNotImplementedException>()), | |
reason: "There is no implementation added to this use case"); | |
})); | |
}); | |
test("Use case must also fail when fetch loan fails from network", () { | |
FetchLoanDetail fetchLoanUseCase = FetchLoanDetail( | |
MockedFailedRateFetchRepository(RateFetchFailType.NETWORK)); | |
fetchLoanUseCase.execute(LoanParamRequest(100, 2), (data) {}, | |
expectAsync1((error) { | |
expect(error, isNot(isInstanceOf<RateFetchFailException>()), | |
reason: | |
"Usecase didn't fail with RateFetchException on network failure"); | |
})); | |
}); | |
test( | |
"EMI must be 150391.64490861617 for amount = 10,000, rate = 15%, time =24 months", | |
() { | |
FetchLoanDetail fetchLoanUseCase = | |
FetchLoanDetail(MockedSucessRateFetchRepository(LoanDetailDTO(15))); | |
fetchLoanUseCase.execute( | |
LoanParamRequest(10000, 24), expectAsync1((data) { | |
expect("150391.64490861617",equals( data._emi),reason: "Emi calculation invalid"); | |
}), (error) { | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment