@@ -104,6 +104,28 @@ public void Can_DeSerialize_TypedContainerDto_with_JsonObject()
104104 Assert . That ( container . Source . Action . ElementId , Is . EqualTo ( fromText . Action . ElementId ) ) ;
105105 }
106106
107+ [ Test ]
108+ public void Can_DeSerialize_TypedContainerDto_into_JsonValueContainerDto ( )
109+ {
110+ var container = new TypedContainerDto {
111+ Source = text ,
112+ Destination = image
113+ } ;
114+
115+ var json = container . ToJson ( ) ;
116+
117+ var fromJson = json . FromJson < JsonValueContainerDto > ( ) ;
118+
119+ var fromText = fromJson . Source . As < TextElementDto > ( ) ;
120+ var fromImage = fromJson . Destination . As < ImageElementDto > ( ) ;
121+
122+ Assert . That ( container . Source . Action . ElementId , Is . EqualTo ( fromText . Action . ElementId ) ) ;
123+ Assert . That ( container . Destination . ElementId , Is . EqualTo ( fromImage . ElementId ) ) ;
124+
125+ Assert . That ( container . Destination . Action , Is . EqualTo ( fromImage . Action ) ) ;
126+ Assert . That ( container . Destination . Content , Is . EqualTo ( fromImage . Content ) ) ;
127+ }
128+
107129 [ Test ]
108130 public void Can_Serialize_StringContainerDto ( )
109131 {
@@ -131,14 +153,21 @@ public class TypedContainerDto
131153 public TextElementDto Source { get ; set ; }
132154 public ImageElementDto Destination { get ; set ; }
133155 }
134-
156+
135157 // DTOs
136158 public class StringContainerDto // This is the request dto
137159 {
138160 public string Source { get ; set ; } // This will be some ElementDto
139161 public string Destination { get ; set ; } // This will be some ElementDto
140162 }
141163
164+ // DTOs
165+ public class JsonValueContainerDto // This is the request dto
166+ {
167+ public JsonValue Source { get ; set ; } // This will be some ElementDto
168+ public JsonValue Destination { get ; set ; } // This will be some ElementDto
169+ }
170+
142171 public class TextElementDto
143172 {
144173 public string ElementType { get ; set ; }
0 commit comments