55
66namespace Orb . Tests . Core ;
77
8- public class ModelBaseTest
8+ public class JsonModelTest
99{
1010 [ Fact ]
1111 public void GetNotNullClass_WhenPresent_Works ( )
1212 {
1313 var dictionary = new Dictionary < string , JsonElement > ( ) ;
14- ModelBase . Set ( dictionary , "key" , "value" ) ;
14+ JsonModel . Set ( dictionary , "key" , "value" ) ;
1515
16- var value = ModelBase . GetNotNullClass < string > ( dictionary , "key" ) ;
16+ var value = JsonModel . GetNotNullClass < string > ( dictionary , "key" ) ;
1717
1818 Assert . Equal ( "value" , value ) ;
1919 }
@@ -24,7 +24,7 @@ public void GetNotNullClass_WhenAbsent_Throws()
2424 var dictionary = new Dictionary < string , JsonElement > ( ) ;
2525
2626 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
27- ModelBase . GetNotNullClass < string > ( dictionary , "key" )
27+ JsonModel . GetNotNullClass < string > ( dictionary , "key" )
2828 ) ;
2929
3030 Assert . Equal ( "'key' cannot be absent" , exception . Message ) ;
@@ -34,10 +34,10 @@ public void GetNotNullClass_WhenAbsent_Throws()
3434 public void GetNotNullClass_WhenNull_Throws ( )
3535 {
3636 var dictionary = new Dictionary < string , JsonElement > ( ) ;
37- ModelBase . Set < string ? > ( dictionary , "key" , null ) ;
37+ JsonModel . Set < string ? > ( dictionary , "key" , null ) ;
3838
3939 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
40- ModelBase . GetNotNullClass < string > ( dictionary , "key" )
40+ JsonModel . GetNotNullClass < string > ( dictionary , "key" )
4141 ) ;
4242
4343 Assert . Equal ( "'key' cannot be null" , exception . Message ) ;
@@ -47,10 +47,10 @@ public void GetNotNullClass_WhenNull_Throws()
4747 public void GetNotNullClass_WhenMismatchedType_Throws ( )
4848 {
4949 var dictionary = new Dictionary < string , JsonElement > ( ) ;
50- ModelBase . Set ( dictionary , "key" , 42 ) ;
50+ JsonModel . Set ( dictionary , "key" , 42 ) ;
5151
5252 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
53- ModelBase . GetNotNullClass < string > ( dictionary , "key" )
53+ JsonModel . GetNotNullClass < string > ( dictionary , "key" )
5454 ) ;
5555
5656 Assert . Equal ( "'key' must be of type System.String" , exception . Message ) ;
@@ -60,9 +60,9 @@ public void GetNotNullClass_WhenMismatchedType_Throws()
6060 public void GetNotNullStruct_WhenPresent_Works ( )
6161 {
6262 var dictionary = new Dictionary < string , JsonElement > ( ) ;
63- ModelBase . Set ( dictionary , "key" , 42 ) ;
63+ JsonModel . Set ( dictionary , "key" , 42 ) ;
6464
65- var value = ModelBase . GetNotNullStruct < int > ( dictionary , "key" ) ;
65+ var value = JsonModel . GetNotNullStruct < int > ( dictionary , "key" ) ;
6666
6767 Assert . Equal ( 42 , value ) ;
6868 }
@@ -73,7 +73,7 @@ public void GetNotNullStruct_WhenAbsent_Throws()
7373 var dictionary = new Dictionary < string , JsonElement > ( ) ;
7474
7575 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
76- ModelBase . GetNotNullStruct < int > ( dictionary , "key" )
76+ JsonModel . GetNotNullStruct < int > ( dictionary , "key" )
7777 ) ;
7878
7979 Assert . Equal ( "'key' cannot be absent" , exception . Message ) ;
@@ -83,10 +83,10 @@ public void GetNotNullStruct_WhenAbsent_Throws()
8383 public void GetNotNullStruct_WhenNull_Throws ( )
8484 {
8585 var dictionary = new Dictionary < string , JsonElement > ( ) ;
86- ModelBase . Set < int ? > ( dictionary , "key" , null ) ;
86+ JsonModel . Set < int ? > ( dictionary , "key" , null ) ;
8787
8888 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
89- ModelBase . GetNotNullStruct < int > ( dictionary , "key" )
89+ JsonModel . GetNotNullStruct < int > ( dictionary , "key" )
9090 ) ;
9191
9292 Assert . Equal ( "'key' cannot be null" , exception . Message ) ;
@@ -96,10 +96,10 @@ public void GetNotNullStruct_WhenNull_Throws()
9696 public void GetNotNullStruct_WhenMismatchedType_Throws ( )
9797 {
9898 var dictionary = new Dictionary < string , JsonElement > ( ) ;
99- ModelBase . Set ( dictionary , "key" , "value" ) ;
99+ JsonModel . Set ( dictionary , "key" , "value" ) ;
100100
101101 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
102- ModelBase . GetNotNullStruct < int > ( dictionary , "key" )
102+ JsonModel . GetNotNullStruct < int > ( dictionary , "key" )
103103 ) ;
104104
105105 Assert . Equal ( "'key' must be of type System.Int32" , exception . Message ) ;
@@ -109,9 +109,9 @@ public void GetNotNullStruct_WhenMismatchedType_Throws()
109109 public void GetNullableClass_WhenPresent_Works ( )
110110 {
111111 var dictionary = new Dictionary < string , JsonElement > ( ) ;
112- ModelBase . Set ( dictionary , "key" , "value" ) ;
112+ JsonModel . Set ( dictionary , "key" , "value" ) ;
113113
114- var value = ModelBase . GetNullableClass < string > ( dictionary , "key" ) ;
114+ var value = JsonModel . GetNullableClass < string > ( dictionary , "key" ) ;
115115
116116 Assert . Equal ( "value" , value ) ;
117117 }
@@ -121,7 +121,7 @@ public void GetNullableClass_WhenAbsent_ReturnsNull()
121121 {
122122 var dictionary = new Dictionary < string , JsonElement > ( ) ;
123123
124- var value = ModelBase . GetNullableClass < string > ( dictionary , "key" ) ;
124+ var value = JsonModel . GetNullableClass < string > ( dictionary , "key" ) ;
125125
126126 Assert . Null ( value ) ;
127127 }
@@ -130,9 +130,9 @@ public void GetNullableClass_WhenAbsent_ReturnsNull()
130130 public void GetNullableClass_WhenNull_ReturnsNull ( )
131131 {
132132 var dictionary = new Dictionary < string , JsonElement > ( ) ;
133- ModelBase . Set < string ? > ( dictionary , "key" , null ) ;
133+ JsonModel . Set < string ? > ( dictionary , "key" , null ) ;
134134
135- var value = ModelBase . GetNullableClass < string > ( dictionary , "key" ) ;
135+ var value = JsonModel . GetNullableClass < string > ( dictionary , "key" ) ;
136136
137137 Assert . Null ( value ) ;
138138 }
@@ -141,10 +141,10 @@ public void GetNullableClass_WhenNull_ReturnsNull()
141141 public void GetNullableClass_WhenMismatchedType_Throws ( )
142142 {
143143 var dictionary = new Dictionary < string , JsonElement > ( ) ;
144- ModelBase . Set ( dictionary , "key" , 42 ) ;
144+ JsonModel . Set ( dictionary , "key" , 42 ) ;
145145
146146 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
147- ModelBase . GetNullableClass < string > ( dictionary , "key" )
147+ JsonModel . GetNullableClass < string > ( dictionary , "key" )
148148 ) ;
149149
150150 Assert . Equal ( "'key' must be of type System.String" , exception . Message ) ;
@@ -154,9 +154,9 @@ public void GetNullableClass_WhenMismatchedType_Throws()
154154 public void GetNullableStruct_WhenPresent_Works ( )
155155 {
156156 var dictionary = new Dictionary < string , JsonElement > ( ) ;
157- ModelBase . Set ( dictionary , "key" , 42 ) ;
157+ JsonModel . Set ( dictionary , "key" , 42 ) ;
158158
159- var value = ModelBase . GetNullableStruct < int > ( dictionary , "key" ) ;
159+ var value = JsonModel . GetNullableStruct < int > ( dictionary , "key" ) ;
160160
161161 Assert . Equal ( 42 , value ) ;
162162 }
@@ -166,7 +166,7 @@ public void GetNullableStruct_WhenAbsent_ReturnsNull()
166166 {
167167 var dictionary = new Dictionary < string , JsonElement > ( ) ;
168168
169- var value = ModelBase . GetNullableStruct < int > ( dictionary , "key" ) ;
169+ var value = JsonModel . GetNullableStruct < int > ( dictionary , "key" ) ;
170170
171171 Assert . Null ( value ) ;
172172 }
@@ -175,9 +175,9 @@ public void GetNullableStruct_WhenAbsent_ReturnsNull()
175175 public void GetNullableStruct_WhenNull_ReturnsNull ( )
176176 {
177177 var dictionary = new Dictionary < string , JsonElement > ( ) ;
178- ModelBase . Set < int ? > ( dictionary , "key" , null ) ;
178+ JsonModel . Set < int ? > ( dictionary , "key" , null ) ;
179179
180- var value = ModelBase . GetNullableStruct < int > ( dictionary , "key" ) ;
180+ var value = JsonModel . GetNullableStruct < int > ( dictionary , "key" ) ;
181181
182182 Assert . Null ( value ) ;
183183 }
@@ -186,10 +186,10 @@ public void GetNullableStruct_WhenNull_ReturnsNull()
186186 public void GetNullableStruct_WhenMismatchedType_Throws ( )
187187 {
188188 var dictionary = new Dictionary < string , JsonElement > ( ) ;
189- ModelBase . Set ( dictionary , "key" , "value" ) ;
189+ JsonModel . Set ( dictionary , "key" , "value" ) ;
190190
191191 var exception = Assert . Throws < OrbInvalidDataException > ( ( ) =>
192- ModelBase . GetNullableStruct < int > ( dictionary , "key" )
192+ JsonModel . GetNullableStruct < int > ( dictionary , "key" )
193193 ) ;
194194
195195 Assert . Equal ( "'key' must be of type System.Int32" , exception . Message ) ;
0 commit comments