@@ -240,6 +240,70 @@ public virtual void EmbeddingOfInstanceOfCustomReferenceTypeWithPropertiesIsCorr
240
240
Assert . Equal ( targetOutput2 , output2 ) ;
241
241
}
242
242
243
+ [ Fact ]
244
+ public virtual void EmbeddingOfInstanceOfAnonymousTypeWithPropertiesIsCorrect ( )
245
+ {
246
+ // Arrange
247
+ var person = new
248
+ {
249
+ FirstName = "John" ,
250
+ LastName = "Doe" ,
251
+ Address = new
252
+ {
253
+ StreetAddress = "103 Elm Street" ,
254
+ City = "Atlanta" ,
255
+ State = "GA" ,
256
+ PostalCode = 30339
257
+ }
258
+ } ;
259
+
260
+ const string input1 = "person.FirstName" ;
261
+ const string targetOutput1 = "John" ;
262
+
263
+ const string input2 = "person.LastName" ;
264
+ const string targetOutput2 = "Doe" ;
265
+
266
+ const string input3 = "person.Address.StreetAddress" ;
267
+ const string targetOutput3 = "103 Elm Street" ;
268
+
269
+ const string input4 = "person.Address.City" ;
270
+ const string targetOutput4 = "Atlanta" ;
271
+
272
+ const string input5 = "person.Address.State" ;
273
+ const string targetOutput5 = "GA" ;
274
+
275
+ const string input6 = "person.Address.PostalCode" ;
276
+ const int targetOutput6 = 30339 ;
277
+
278
+ // Act
279
+ string output1 ;
280
+ string output2 ;
281
+ string output3 ;
282
+ string output4 ;
283
+ string output5 ;
284
+ int output6 ;
285
+
286
+ using ( var jsEngine = CreateJsEngine ( ) )
287
+ {
288
+ jsEngine . EmbedHostObject ( "person" , person ) ;
289
+
290
+ output1 = jsEngine . Evaluate < string > ( input1 ) ;
291
+ output2 = jsEngine . Evaluate < string > ( input2 ) ;
292
+ output3 = jsEngine . Evaluate < string > ( input3 ) ;
293
+ output4 = jsEngine . Evaluate < string > ( input4 ) ;
294
+ output5 = jsEngine . Evaluate < string > ( input5 ) ;
295
+ output6 = jsEngine . Evaluate < int > ( input6 ) ;
296
+ }
297
+
298
+ // Assert
299
+ Assert . Equal ( targetOutput1 , output1 ) ;
300
+ Assert . Equal ( targetOutput2 , output2 ) ;
301
+ Assert . Equal ( targetOutput3 , output3 ) ;
302
+ Assert . Equal ( targetOutput4 , output4 ) ;
303
+ Assert . Equal ( targetOutput5 , output5 ) ;
304
+ Assert . Equal ( targetOutput6 , output6 ) ;
305
+ }
306
+
243
307
#endregion
244
308
245
309
#region Objects with methods
0 commit comments