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