@@ -63,7 +63,18 @@ public void ShouldSerializeAndDeserializeFromFile(string rootTypeName, string js
63
63
Path . GetFileName ( jsonFilePath ) ) ;
64
64
}
65
65
66
- private void DeserializeSerializeAndAssert ( string rootTypeName , string jsonAsString , string fileName )
66
+ [ Fact ]
67
+ public void ShouldSerializeAndDeserializeFromFileWithAbsolutePath ( )
68
+ {
69
+ const string relativePath = "RealWorldExamples/jsonOrgExample1.json" ;
70
+ DeserializeSerializeAndAssert (
71
+ "JsonOrgExample1" ,
72
+ EmbeddedResource . GetContent ( relativePath , System . Reflection . Assembly . GetExecutingAssembly ( ) ) ,
73
+ Path . Combine ( "C:\\ temp" , Path . GetFileName ( relativePath ) ) ,
74
+ "C.Temp." ) ;
75
+ }
76
+
77
+ private void DeserializeSerializeAndAssert ( string rootTypeName , string jsonAsString , string fileName , string prefixPath = "" )
67
78
{
68
79
string source = $@ "using System;
69
80
using System.IO;
@@ -80,9 +91,8 @@ public static string RunTest()
80
91
streamWriter.Write(@""{ jsonAsString . Replace ( "\" " , "\" \" " ) } "");
81
92
streamWriter.Flush();
82
93
readStream.Position = 0;
83
-
84
- var ser = new DataContractJsonSerializer(typeof(TestImplementation.Json.{ rootTypeName } .{ rootTypeName } ));
85
- var rootType = (TestImplementation.Json.{ rootTypeName } .{ rootTypeName } ) ser.ReadObject(readStream);
94
+ var ser = new DataContractJsonSerializer(typeof(TestImplementation.Json.{ prefixPath } { rootTypeName } .{ rootTypeName } ));
95
+ var rootType = (TestImplementation.Json.{ prefixPath } { rootTypeName } .{ rootTypeName } ) ser.ReadObject(readStream);
86
96
87
97
var writeStream = new MemoryStream();
88
98
ser.WriteObject(writeStream, rootType);
0 commit comments