Skip to content

Instantly share code, notes, and snippets.

@antklim
Last active November 9, 2020 20:41
Show Gist options
  • Save antklim/aea8de49010aa814948ad93df6ce8da7 to your computer and use it in GitHub Desktop.
Save antklim/aea8de49010aa814948ad93df6ce8da7 to your computer and use it in GitHub Desktop.
void main() {
group('Calculator use case', () {
group('calculates value of', () {
Map<CalculatorUseCase, num> testCases = {
CalculatorUseCase(operation: Operation.addition, operandA: 1, operandB: 2): 3,
...
};
testCases.forEach((useCase, expected) {
test('${useCase.operation}', () {
expect(useCase.value, expected);
});
});
});
group('formats', () {
Map<CalculatorUseCase, String> testCases = {
CalculatorUseCase(operation: Operation.addition, operandA: 1, operandB: 2): '1 + 2',
...
};
testCases.forEach((useCase, expected) {
test('${useCase.operation}', () {
expect(useCase.format, expected);
});
});
});
test('sets operation', () {
CalculatorUseCase useCase = CalculatorUseCase(operation: Operation.addition, operandA: 1, operandB: 2);
expect(useCase.operation, Operation.addition);
useCase.setOperation(Operation.subtraction);
expect(useCase.operation, Operation.subtraction);
});
test('sets operands', () {...});
test('sets operands from memory', () {...});
test('manages memory', () {...});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment