예제 #1
0
 /// <summary>
 ///  Helper method to create the expected result callback for a URI test.
 /// </summary>
 /// <param name="uri">The URI that is the expected result.</param>
 /// <param name="testCase">The <see cref="UriTestCase"/> to create the result callback for.</param>
 /// <returns>The expected result callback for a URI test.</returns>
 private PayloadWriterTestDescriptor.WriterTestExpectedResultCallback CreateUriTestCaseExpectedResultCallback(
     Uri baseUri,
     Uri uri,
     UriTestCase testCase)
 {
     return((testConfiguration) =>
     {
         if (testConfiguration.Format == ODataFormat.Json)
         {
             // In JSON we always expect an absolute URI
             string absoluteEscapedUri = TestUriUtils.ToAbsoluteUriString(uri, baseUri);
             return new JsonWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
             {
                 Json = "\"" + absoluteEscapedUri + "\"",
                 FragmentExtractor = json => testCase.JsonExtractor(testConfiguration, json)
             };
         }
         else
         {
             throw new NotSupportedException("Unsupported format " + testConfiguration.Format.ToString() + " found.");
         }
     });
 }
예제 #2
0
 /// <summary>
 ///  Helper method to create the expected result callback for a URI test.
 /// </summary>
 /// <param name="uri">The URI that is the expected result.</param>
 /// <param name="testCase">The <see cref="UriTestCase"/> to create the result callback for.</param>
 /// <returns>The expected result callback for a URI test.</returns>
 private PayloadWriterTestDescriptor.WriterTestExpectedResultCallback CreateUriTestCaseExpectedResultCallback(
     Uri baseUri, 
     Uri uri,
     UriTestCase testCase)
 {
     return (testConfiguration) =>
     {
         if (testConfiguration.Format == ODataFormat.Atom)
         {
             // In ATOM we expect an escaped URI
             string escapedUri = TestUriUtils.ToEscapedUriString(uri);
             return new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
             {
                 Xml = "<uri>" + escapedUri + "</uri>",
                 FragmentExtractor = element => testCase.AtomExtractor(testConfiguration, element),
             };
         }
         else if (testConfiguration.Format == ODataFormat.Json)
         {
             // In JSON we always expect an absolute URI
             string absoluteEscapedUri = TestUriUtils.ToAbsoluteUriString(uri, baseUri);
             return new JsonWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
             {
                 Json = "\"" + absoluteEscapedUri + "\"",
                 FragmentExtractor = json => testCase.JsonExtractor(testConfiguration, json)
             };
         }
         else
         {
             throw new NotSupportedException("Unsupported format " + testConfiguration.Format.ToString() + " found.");
         }
     };
 }