This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change 1- using System . Linq ;
1+ using System . Collections . Generic ;
2+ using System . Linq ;
23using NUnit . Framework ;
34
45namespace ServiceStack . Text . Tests
@@ -128,5 +129,42 @@ public void Can_deserialize_JSON_Object()
128129 Assert . That ( items [ "value" ] , Is . EqualTo ( "val1" ) ) ;
129130 Assert . That ( items [ "type" ] , Is . EqualTo ( "val2" ) ) ;
130131 }
132+
133+ public class Customer
134+ {
135+ public static List < object > Setters = new List < object > ( ) ;
136+
137+ private string name ;
138+ private int age ;
139+ private string address ;
140+
141+ public string Name
142+ {
143+ get { return name ; }
144+ set { name = value ; Setters . Add ( value ) ; }
145+ }
146+
147+ public int Age
148+ {
149+ get { return age ; }
150+ set { age = value ; Setters . Add ( value ) ; }
151+ }
152+
153+ public string Address
154+ {
155+ get { return address ; }
156+ set { address = value ; Setters . Add ( value ) ; }
157+ }
158+ }
159+
160+ [ Test ]
161+ public void Only_sets_Setters_with_JSON ( )
162+ {
163+ var dto = "{\" Name\" :\" Foo\" }" . FromJson < Customer > ( ) ;
164+
165+ Assert . That ( dto . Name , Is . EqualTo ( "Foo" ) ) ;
166+ Assert . That ( Customer . Setters . Count , Is . EqualTo ( 1 ) ) ;
167+ Assert . That ( Customer . Setters [ 0 ] , Is . EqualTo ( dto . Name ) ) ;
168+ }
131169 }
132170}
You can’t perform that action at this time.
0 commit comments