public static IWireMockServer WithMappingFromOpenApiDocument(this IWireMockServer server, OpenApiDocument document, WireMockOpenApiParserSettings settings = null) { Guard.NotNull(server, nameof(server)); Guard.NotNull(document, nameof(document)); var mappings = new WireMockOpenApiParser().FromDocument(document, settings); return(server.WithMapping(mappings.ToArray())); }
public static IWireMockServer WithMappingFromOpenApiFile(this IWireMockServer server, string path, WireMockOpenApiParserSettings settings, out OpenApiDiagnostic diagnostic) { Guard.NotNull(server, nameof(server)); Guard.NotNullOrEmpty(path, nameof(path)); var mappings = new WireMockOpenApiParser().FromFile(path, settings, out diagnostic); return(server.WithMapping(mappings.ToArray())); }
public static IWireMockServer WithMappingFromOpenApiStream(this IWireMockServer server, Stream stream, WireMockOpenApiParserSettings settings, out OpenApiDiagnostic diagnostic) { Guard.NotNull(server, nameof(server)); Guard.NotNull(stream, nameof(stream)); Guard.NotNull(settings, nameof(settings)); var mappings = new WireMockOpenApiParser().FromStream(stream, settings, out diagnostic); return(server.WithMapping(mappings.ToArray())); }
public void StartWebApp() { _staticApiServer = MockApiServer.Start(); var webApp = new CustomWebApplicationFactory <Startup>(); _server = webApp.Server; _staticClient = new CustomWebApplicationFactory <Startup>().CreateClient(new WebApplicationFactoryClientOptions { HandleCookies = false }); _context.Set(_server, ContextKeys.TestServer); _context.Set(_staticClient, ContextKeys.HttpClient); }
/// <summary> /// Register the mappings via an OpenAPI (swagger) V2 or V3 file. /// </summary> /// <param name="server">The WireMockServer instance</param> /// <param name="path">Path containing OpenAPI file to parse and use the mappings.</param> /// <param name="diagnostic">Returns diagnostic object containing errors detected during parsing</param> public static IWireMockServer WithMappingFromOpenApiFile(this IWireMockServer server, string path, out OpenApiDiagnostic diagnostic) { if (server == null) { throw new ArgumentNullException(nameof(server)); } if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } var mappings = new WireMockOpenApiParser().FromFile(path, out diagnostic); return(server.WithMapping(mappings.ToArray())); }
/// <summary> /// Returns a <see cref="WireMockReceivedAssertions"/> object that can be used to assert the current <see cref="IWireMockServer"/>. /// </summary> /// <param name="instance">The WireMockServer</param> /// <returns><see cref="WireMockReceivedAssertions"/></returns> public static WireMockReceivedAssertions Should(this IWireMockServer instance) { return(new WireMockReceivedAssertions(instance)); }
public WireMockANumberOfCallsAssertions(IWireMockServer server, int callsCount) { _server = server; _callsCount = callsCount; }
public static void StartEnvironment() { _staticServer = MockApiServer.Start(); _staticClient = new WebApplicationFactory <Startup>().CreateClient(); }
/// <summary> /// Register the mappings via an OpenAPI (swagger) V2 or V3 document. /// </summary> /// <param name="server">The WireMockServer instance</param> /// <param name="document">The OpenAPI document to use as mappings.</param> public static IWireMockServer WithMappingFromOpenApiDocument(this IWireMockServer server, OpenApiDocument document) { var mappings = new WireMockOpenApiParser().FromDocument(document); return(server.WithMapping(mappings.ToArray())); }
/// <summary> /// Register the mappings via an OpenAPI (swagger) V2 or V3 stream. /// </summary> /// <param name="server">The WireMockServer instance</param> /// <param name="stream">Stream containing OpenAPI description to parse and use the mappings.</param> /// <param name="diagnostic">Returns diagnostic object containing errors detected during parsing</param> public static IWireMockServer WithMappingFromOpenApiStream(this IWireMockServer server, Stream stream, out OpenApiDiagnostic diagnostic) { var mappings = new WireMockOpenApiParser().FromStream(stream, out diagnostic); return(server.WithMapping(mappings.ToArray())); }
public WireMockAssertions(IWireMockServer subject, int?callsCount) { _subject = subject; }
public static IWireMockServer WithMappingFromOpenApiStream(this IWireMockServer server, Stream stream, out OpenApiDiagnostic diagnostic) { return(WithMappingFromOpenApiStream(server, stream, null, out diagnostic)); }
public static IWireMockServer WithMappingFromOpenApiFile(this IWireMockServer server, string path, out OpenApiDiagnostic diagnostic) { return(WithMappingFromOpenApiFile(server, path, null, out diagnostic)); }