コード例 #1
0
 public static void EnsureWrite(this IMockDataProvider sut, JSchema schema)
 {
     if (!TryGetMockData(sut, schema, out _))
     {
         throw new XunitException($"{sut.GetType().Name} is expected to write given schema, but did not.");
     }
 }
コード例 #2
0
 public static string GetMockData(this IMockDataProvider sut, JSchema schema)
 {
     if (TryGetMockData(sut, schema, out var data))
     {
         return(data);
     }
     throw new XunitException($"{sut.GetType().Name} is expected to write value, but did not.");
 }
コード例 #3
0
        private static bool TryGetMockData(this IMockDataProvider sut, JSchema schema, out string mockData)
        {
            using (var textWriter = new StringWriter())
            {
                var writer    = new OpenApiJsonWriter(textWriter);
                var isWritten = sut.TryWriteValue(writer, schema);
                mockData = isWritten ? textWriter.ToString() : null;

                return(isWritten);
            }
        }
コード例 #4
0
 public DefaultRequestHandler(
     Options config,
     IRequestValidator requestValidator,
     IResponseValidator responseValidator,
     IMockDataProvider exampleProvider,
     IHttpClientFactory httpClientFactory)
 {
     Config            = config;
     RequestValidator  = requestValidator;
     ResponseValidator = responseValidator;
     ExampleProvider   = exampleProvider;
     HttpClientFactory = httpClientFactory;
 }
コード例 #5
0
 public MockHandler(IMockDataProvider dataProvider)
 {
     DataProvider = dataProvider;
 }