-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
paintroid-765 add star and heart shape unit tests
- Loading branch information
1 parent
b3d2be9
commit 3652d58
Showing
6 changed files
with
184 additions
and
4 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
43 changes: 43 additions & 0 deletions
43
test/unit/serialization/command/heart_shape_serializer_test.dart
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,43 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:paintroid/core/commands/command_implementation/graphic/shape/heart_shape_command.dart'; | ||
import 'package:paintroid/core/json_serialization/versioning/serializer_version.dart'; | ||
|
||
import '../utils/dummy_command_factory.dart'; | ||
import '../utils/dummy_paint_factory.dart'; | ||
|
||
void main() { | ||
group('Version 1', () { | ||
test('Test Star serialization', () { | ||
const type = SerializerType.HEART_SHAPE_COMMAND; | ||
final originalPaint = DummyPaintFactory.createPaint(version: Version.v1); | ||
const center = Offset(100, 100); | ||
const width = 50.0; | ||
const height = 50.0; | ||
const angle = 0.0; | ||
|
||
final command = DummyCommandFactory.createHeartShapeCommand( | ||
originalPaint, | ||
width, | ||
height, | ||
angle, | ||
center, | ||
); | ||
|
||
final deserializedCommand = HeartShapeCommand.fromJson(command.toJson()); | ||
|
||
expect( | ||
DummyPaintFactory.comparePaint( | ||
originalPaint, | ||
deserializedCommand.paint, | ||
version: Version.v1, | ||
), | ||
isTrue); | ||
expect(command.version, equals(deserializedCommand.version)); | ||
expect(deserializedCommand.center, equals(center)); | ||
expect(deserializedCommand.type, equals(type)); | ||
expect(deserializedCommand.angle, equals(angle)); | ||
expect(deserializedCommand.width, equals(width)); | ||
expect(deserializedCommand.height, equals(height)); | ||
}); | ||
}); | ||
} |
42 changes: 42 additions & 0 deletions
42
test/unit/serialization/command/star_shape_serializer_test.dart
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,42 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:paintroid/core/commands/command_implementation/graphic/shape/star_shape_command.dart'; | ||
import 'package:paintroid/core/json_serialization/versioning/serializer_version.dart'; | ||
|
||
import '../utils/dummy_command_factory.dart'; | ||
import '../utils/dummy_paint_factory.dart'; | ||
|
||
void main() { | ||
group('Version 1', () { | ||
test('Test Star serialization', () { | ||
const type = SerializerType.STAR_SHAPE_COMMAND; | ||
final originalPaint = DummyPaintFactory.createPaint(version: Version.v1); | ||
const center = Offset(100, 100); | ||
const radius = 50.0; | ||
const numberOfPoints = 5; | ||
const angle = 0.0; | ||
final command = DummyCommandFactory.createStarShapeCommand( | ||
originalPaint, | ||
numberOfPoints, | ||
radius, | ||
angle, | ||
center, | ||
); | ||
|
||
final deserializedCommand = StarShapeCommand.fromJson(command.toJson()); | ||
|
||
expect( | ||
DummyPaintFactory.comparePaint( | ||
originalPaint, | ||
deserializedCommand.paint, | ||
version: Version.v1, | ||
), | ||
isTrue); | ||
expect(command.version, equals(deserializedCommand.version)); | ||
expect(deserializedCommand.center, equals(center)); | ||
expect(deserializedCommand.radius, equals(radius)); | ||
expect(deserializedCommand.type, equals(type)); | ||
expect(deserializedCommand.numberOfPoints, equals(numberOfPoints)); | ||
expect(deserializedCommand.angle, equals(angle)); | ||
}); | ||
}); | ||
} |
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