runTest method

void runTest()

Runs the test.

Implementation

void runTest() {
  for (final entry in _testCases.entries) {
    for (final obj in entry.value) {
      final stateMachine = _createStateMachine(entry.key)
        ..dispatch(obj.action);
      test(
        'When ${entry.key.runtimeType} dispatch ${obj.action.runtimeType}',
        () {
          if (stateMachine.isPrevTransitionValid) {
            if (stateMachine.state != obj.afterState) {
              fail(
                // ignore: lines_longer_than_80_chars
                'The state after the transition is different from the expected value'
                '\n${obj.createFailMessage(stateMachine)}',
              );
            }
            for (final e in stateMachine.createdSideEffect) {
              final matchedSideEffect =
                  obj.createdSideEffect.firstWhereOrNull(
                (element) => element.runtimeType == e.runtimeType,
              );
              if (matchedSideEffect == null) {
                fail(
                  // ignore: lines_longer_than_80_chars
                  'A different side effect was generated from the expected value'
                  '\n${obj.createFailMessage(stateMachine)}',
                );
              }
            }
          }
        },
      );
      stateMachine.close();
    }
  }
}