Beispiel #1
0
 public void TestJsonParser()
 {
     var parser = ParserFactory.GetDataParser(DataType.Json);
     var sampleObject = new ErrorResponse() { Code = 0, Reason = "Unit testing" };
     var sampleObjectAsString = parser.SerializeData(sampleObject);
     Assert.IsTrue(sampleObjectAsString.Contains("{\"Reason\":\"Unit testing\",\"Code\":0}"));
     var sampleObjectParsed = parser.ParseData<ErrorResponse>(sampleObjectAsString);
     Assert.IsTrue(sampleObjectParsed.Reason.Equals(sampleObject.Reason) && sampleObjectParsed.Code == sampleObject.Code);
 }
Beispiel #2
0
 private static string ConvertErrorToString(ErrorResponse error, DataType responseFormat)
 {
     return ParserFactory.GetDataParser(responseFormat).SerializeData(error);
 }