-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!:
isEnabled
getter and setter (#65)
Removed setEnabled and isEnabled. Also updated documentation for the new getter and setter. // Before: contact.setEnabled(true); contact.isEnabled(); // true // After: contact.isEnabled = true; contact.isEnabled; // true
- Loading branch information
Showing
3 changed files
with
92 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'package:forge2d/forge2d.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
class _MockFixture extends Mock implements Fixture {} | ||
|
||
class _TestContact extends Contact { | ||
_TestContact( | ||
super.fixtureA, | ||
super.indexA, | ||
super.fixtureB, | ||
super.indexB, | ||
); | ||
|
||
@override | ||
void evaluate(_, __, ___) => throw UnimplementedError(); | ||
} | ||
|
||
void main() { | ||
group('Contact', () { | ||
late Fixture fixtureA; | ||
late int indexA; | ||
late Fixture fixtureB; | ||
late int indexB; | ||
|
||
setUp(() { | ||
fixtureA = _MockFixture(); | ||
when(() => fixtureA.friction).thenReturn(0); | ||
when(() => fixtureA.restitution).thenReturn(0); | ||
|
||
fixtureB = _MockFixture(); | ||
when(() => fixtureB.friction).thenReturn(0); | ||
when(() => fixtureB.restitution).thenReturn(0); | ||
|
||
indexA = 0; | ||
indexB = 0; | ||
}); | ||
|
||
test('can be instantiated', () { | ||
expect( | ||
_TestContact( | ||
fixtureA, | ||
indexA, | ||
fixtureB, | ||
indexB, | ||
), | ||
isA<Contact>(), | ||
); | ||
}); | ||
|
||
group('isEnabled', () { | ||
test('true by default', () { | ||
final contact = _TestContact( | ||
fixtureA, | ||
indexA, | ||
fixtureB, | ||
indexB, | ||
); | ||
|
||
expect(contact.isEnabled, isTrue); | ||
}); | ||
|
||
test('can change', () { | ||
final contact = _TestContact( | ||
fixtureA, | ||
indexA, | ||
fixtureB, | ||
indexB, | ||
); | ||
|
||
final newIsEnabled = !contact.isEnabled; | ||
contact.isEnabled = newIsEnabled; | ||
|
||
expect(contact.isEnabled, equals(newIsEnabled)); | ||
}); | ||
}); | ||
}); | ||
} |