1
1
part of json_mapper.test;
2
2
3
+ @jsonSerializable
4
+ class User {
5
+ String _email;
6
+
7
+ String get email => _email;
8
+
9
+ set email (String email) => _email = email;
10
+ }
11
+
3
12
@jsonSerializable
4
13
class Foo {
5
14
final Bar bar;
@@ -20,6 +29,7 @@ class Baz {}
20
29
21
30
class Base <T > {
22
31
final T value;
32
+
23
33
Base (this .value);
24
34
}
25
35
@@ -34,41 +44,46 @@ class Pt {
34
44
}
35
45
36
46
@jsonSerializable
37
- class PtDerived extends Base <Pt >{
47
+ class PtDerived extends Base <Pt > {
38
48
PtDerived (Pt value) : super (value);
39
49
}
40
50
41
51
@jsonSerializable
42
52
class StringListClass {
43
53
List <String > list;
54
+
44
55
StringListClass (this .list);
45
56
}
46
57
47
58
@jsonSerializable
48
59
class PositionalParametersClass {
49
60
String firstName;
50
61
String lastName;
62
+
51
63
PositionalParametersClass (this .firstName, this .lastName);
52
64
}
53
65
54
66
@jsonSerializable
55
67
class OptionalParametersClass {
56
68
String firstName;
57
69
String lastName;
70
+
58
71
OptionalParametersClass ([this .firstName, this .lastName]);
59
72
}
60
73
61
74
@jsonSerializable
62
75
class PartiallyOptionalParametersClass {
63
76
String firstName;
64
77
String lastName;
78
+
65
79
PartiallyOptionalParametersClass (this .firstName, [this .lastName]);
66
80
}
67
81
68
82
@jsonSerializable
69
83
class NamedParametersClass {
70
84
String firstName;
71
85
String lastName;
86
+
72
87
NamedParametersClass ({this .firstName, this .lastName});
73
88
}
74
89
@@ -158,6 +173,16 @@ testConstructors() {
158
173
expect (pTargetJson, '{"value":{}}' );
159
174
});
160
175
176
+ test ("User class, getter/setter property w/o constructor" , () {
177
+ // given
178
+ final User user = User ();
179
+
180
+ // when
181
+ final json = JsonMapper .serialize (user, '' );
182
+ // then
183
+ expect (json,
'{"email":"[email protected] "}' );
184
+ });
185
+
161
186
test ("StringListClass class" , () {
162
187
// given
163
188
// when
0 commit comments