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."); } }
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."); }
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); } }
public DefaultRequestHandler( Options config, IRequestValidator requestValidator, IResponseValidator responseValidator, IMockDataProvider exampleProvider, IHttpClientFactory httpClientFactory) { Config = config; RequestValidator = requestValidator; ResponseValidator = responseValidator; ExampleProvider = exampleProvider; HttpClientFactory = httpClientFactory; }
public MockHandler(IMockDataProvider dataProvider) { DataProvider = dataProvider; }