Пример #1
0
        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()));
        }
Пример #2
0
        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()));
        }
Пример #3
0
        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()));
        }
Пример #4
0
        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()));
        }
Пример #6
0
 /// <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));
 }
Пример #7
0
 public WireMockANumberOfCallsAssertions(IWireMockServer server, int callsCount)
 {
     _server     = server;
     _callsCount = callsCount;
 }
Пример #8
0
 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()));
        }
Пример #11
0
 public WireMockAssertions(IWireMockServer subject, int?callsCount)
 {
     _subject = subject;
 }
Пример #12
0
 public static IWireMockServer WithMappingFromOpenApiStream(this IWireMockServer server, Stream stream, out OpenApiDiagnostic diagnostic)
 {
     return(WithMappingFromOpenApiStream(server, stream, null, out diagnostic));
 }
Пример #13
0
 public static IWireMockServer WithMappingFromOpenApiFile(this IWireMockServer server, string path, out OpenApiDiagnostic diagnostic)
 {
     return(WithMappingFromOpenApiFile(server, path, null, out diagnostic));
 }