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
class EMICalculator { | |
final double amount, rate, time; | |
EMICalculator(this.amount, this.rate, this.time); | |
double calculateEMI() | |
{ | |
return amount*rate*(1 + rate)*time/((1+rate)*time-1); | |
} | |
} |
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
void main() | |
{ | |
test("EMI cannot be zero",() | |
{ | |
EMICalculator emiCalculator=EMICalculator(1,2,3); | |
//Performing assertion | |
expect(emiCalculator.calculateEMI(),greaterThan(0),reason:"EMI calculated is zero"); | |
}); | |
} |
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
//Domain Entity responsible for calculating EMI for given params. | |
class EMICalculator { | |
final double amount, rate, time; | |
EMICalculator(this.amount, this.rate, this.time); | |
double calculateEMI() | |
{ | |
return -1; | |
} |
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
void main() | |
{ | |
test("Amount cannot be null",() | |
{ | |
EMICalculator emiCalculator=EMICalculator(1,2,3); | |
//Performing assertion | |
expect(emiCalculator.amount,isNot(null), reason:"Amount cannot be null"); | |
}); |
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
//Domain Entity responsible for calculating EMI for given params. | |
class EMICalculator { | |
final double amount, rate, time; | |
EMICalculator(this.amount, this.rate, this.time); | |
} |
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
void main() | |
{ | |
test("Amount cannot be null",() | |
{ | |
EMICalculator emiCalculator=EMICalculator(); | |
//Performing assertion | |
expect(emiCalculator.amount,isNot(null), reason:"Amount cannot be null"); | |
}); |
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
//Domain Entity responsible for calculating EMI for given params. | |
class EMICalculator | |
{ | |
double? amount,rate,time; | |
} |
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
//Usecase Implementation | |
class ValidateBillingAndShippingAddressUseCase extends UseCase< | |
BillingAndShippingAddressValidationRequest, | |
BillingAndShippingAddressValidationResponse> { | |
final AddressRespository _addressRespository; | |
ValidateBillingAndShippingAddressUseCase(this._addressRespository); | |
@override | |
Stream<BillingAndShippingAddressValidationResponse> buildUseCase( |
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
//Usecase Implementation | |
class PostBillingInfoUseCase | |
extends UseCase<BillingInfoRequest, BillingInfoResponse> { | |
final BillingInfoRepository _billingInfoRepository; | |
PostBillingInfoUseCase(this._billingInfoRepository); | |
@override | |
Stream<BillingInfoResponse> buildUseCase(BillingInfoRequest param) { | |
return _billingInfoRepository.postBillingInfo(param).asStream(); |
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
abstract class BaseUseCase<P, R> { | |
Stream<R> buildUseCase(P param); | |
StreamSubscription<R> execute(P param,void Function(R) result,void Function(String) error) | |
{ | |
return buildUseCase(param).listen(result,onError: (Object exception, StackTrace stackTrace){ | |
error(exception.toString()); | |
}); | |
} |