コード例 #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);
        }
コード例 #5
0
        /// <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();
 }
コード例 #9
0
        /// <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()));
        }
コード例 #10
0
        /// <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));
 }