Skip to content

Commit

Permalink
RAP-2055 Utilize long term pattern for setting module name
Browse files Browse the repository at this point in the history
  • Loading branch information
bencampbell-wf committed Jul 10, 2017
1 parent 8937b5d commit fa99f60
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions test/lifecycle_module_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class MockStreamSubscription extends Mock implements StreamSubscription<Null> {}
class TestLifecycleModule extends LifecycleModule {
Iterable<StreamSubscription<LifecycleModule>> _eventListStreamSubscriptions;
bool _managedDisposerWasCalled = false;
String _name;

final Disposable managedDisposable;
final StreamController<Null> managedStreamController;
Expand All @@ -46,22 +45,18 @@ class TestLifecycleModule extends LifecycleModule {
Error onWillLoadChildModuleError;
Error onWillUnloadChildModuleError;

@override
final String name;

// mock data to be used for test validation
List<String> eventList;
bool mockShouldUnload;

factory TestLifecycleModule() {
return new TestLifecycleModule.withModuleName('TestLifecycleMethod');
}

factory TestLifecycleModule.withModuleName(String name) {
return new TestLifecycleModule._(name);
}

TestLifecycleModule._(this._name)
TestLifecycleModule({String name})
: managedDisposable = new Disposable(),
managedStreamController = new StreamController<Null>(),
managedStreamSubscription = new MockStreamSubscription() {
managedStreamSubscription = new MockStreamSubscription(),
name = name ?? 'TestLifecycleModule' {
// init test validation data
eventList = [];
mockShouldUnload = true;
Expand Down Expand Up @@ -107,9 +102,6 @@ class TestLifecycleModule extends LifecycleModule {

bool get managedDisposerWasCalled => _managedDisposerWasCalled;

@override
String get name => _name;

// Overriding without re-applying the @protected annotation allows us to call
// loadChildModule in our tests below.
@override
Expand Down Expand Up @@ -957,10 +949,8 @@ void main() {
TestLifecycleModule parentModule;

setUp(() async {
parentModule =
new TestLifecycleModule.withModuleName('Parent-TestLifecycleModule');
childModule =
new TestLifecycleModule.withModuleName('Child-TestLifecycleModule');
parentModule = new TestLifecycleModule(name: 'parent');
childModule = new TestLifecycleModule(name: 'child');
await parentModule.load();
});

Expand Down

0 comments on commit fa99f60

Please sign in to comment.