diff --git a/WireMock.Net Solution.sln b/WireMock.Net Solution.sln index 2daabca0..104064bd 100644 --- a/WireMock.Net Solution.sln +++ b/WireMock.Net Solution.sln @@ -47,8 +47,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.StandAlone.NET EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net452", "examples\WireMock.Net.StandAlone.Net452\WireMock.Net.StandAlone.Net452.csproj", "{668F689E-57B4-422E-8846-C0FF643CA999}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication\WireMock.Net.WebApplication.NETCore2.csproj", "{049539C1-7A66-4559-AD7A-B1C73B97CBB0}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Proxy.Net452", "examples\WireMock.Net.Console.Proxy.Net452\WireMock.Net.Console.Proxy.Net452.csproj", "{26433A8F-BF01-4962-97EB-81BFFBB61096}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net461", "examples\WireMock.Net.StandAlone.Net461\WireMock.Net.StandAlone.Net461.csproj", "{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}" @@ -69,6 +67,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.FluentAssertions", "src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A95}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication.NETCore2\WireMock.Net.WebApplication.NETCore2.csproj", "{6F38CB3A-6DA1-408A-AECD-E434523C2838}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore3", "examples\WireMock.Net.WebApplication.NETCore3\WireMock.Net.WebApplication.NETCore3.csproj", "{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -123,10 +125,6 @@ Global {668F689E-57B4-422E-8846-C0FF643CA999}.Debug|Any CPU.Build.0 = Debug|Any CPU {668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.ActiveCfg = Release|Any CPU {668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.Build.0 = Release|Any CPU - {049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.Build.0 = Release|Any CPU {26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.Build.0 = Debug|Any CPU {26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -167,6 +165,14 @@ Global {B6269AAC-170A-4346-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU + {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.Build.0 = Release|Any CPU + {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -184,7 +190,6 @@ Global {1995E414-F197-4AB4-90C2-68D806B5AF59} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {10E16614-61CA-48D8-8BDD-664C13913DED} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {668F689E-57B4-422E-8846-C0FF643CA999} = {985E0ADB-D4B4-473A-AA40-567E279B7946} - {049539C1-7A66-4559-AD7A-B1C73B97CBB0} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {26433A8F-BF01-4962-97EB-81BFFBB61096} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {3C279524-DB73-4DE3-BEF1-F2B2958C9F65} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {7F0B2446-0363-4720-AF46-F47F83B557DC} = {985E0ADB-D4B4-473A-AA40-567E279B7946} @@ -195,6 +200,8 @@ Global {D3804228-91F4-4502-9595-39584E5AADAD} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} {5C09FB93-1535-4F92-AF26-21E8A061EE4A} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {B6269AAC-170A-4346-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} + {6F38CB3A-6DA1-408A-AECD-E434523C2838} = {985E0ADB-D4B4-473A-AA40-567E279B7946} + {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4} = {985E0ADB-D4B4-473A-AA40-567E279B7946} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458} diff --git a/examples/WireMock.Net.WebApplication/App.cs b/examples/WireMock.Net.WebApplication.NETCore2/App.cs similarity index 95% rename from examples/WireMock.Net.WebApplication/App.cs rename to examples/WireMock.Net.WebApplication.NETCore2/App.cs index fc63803f..2575335b 100644 --- a/examples/WireMock.Net.WebApplication/App.cs +++ b/examples/WireMock.Net.WebApplication.NETCore2/App.cs @@ -1,22 +1,22 @@ -using Microsoft.Extensions.Logging; - -namespace WireMock.Net.WebApplication -{ - public class App - { - private readonly IWireMockService _service; - private readonly ILogger _logger; - - public App(IWireMockService service, ILogger logger) - { - _service = service; - _logger = logger; - } - - public void Run() - { - _logger.LogInformation("WireMock.Net App running"); - _service.Run(); - } - } +using Microsoft.Extensions.Logging; + +namespace WireMock.Net.WebApplication +{ + public class App + { + private readonly IWireMockService _service; + private readonly ILogger _logger; + + public App(IWireMockService service, ILogger logger) + { + _service = service; + _logger = logger; + } + + public void Run() + { + _logger.LogInformation("WireMock.Net App running"); + _service.Run(); + } + } } \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/IWireMockService.cs b/examples/WireMock.Net.WebApplication.NETCore2/IWireMockService.cs similarity index 94% rename from examples/WireMock.Net.WebApplication/IWireMockService.cs rename to examples/WireMock.Net.WebApplication.NETCore2/IWireMockService.cs index f99c23e4..de3ac175 100644 --- a/examples/WireMock.Net.WebApplication/IWireMockService.cs +++ b/examples/WireMock.Net.WebApplication.NETCore2/IWireMockService.cs @@ -1,7 +1,7 @@ -namespace WireMock.Net.WebApplication -{ - public interface IWireMockService - { - void Run(); - } +namespace WireMock.Net.WebApplication +{ + public interface IWireMockService + { + void Run(); + } } \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/Program.cs b/examples/WireMock.Net.WebApplication.NETCore2/Program.cs similarity index 100% rename from examples/WireMock.Net.WebApplication/Program.cs rename to examples/WireMock.Net.WebApplication.NETCore2/Program.cs diff --git a/examples/WireMock.Net.WebApplication/Properties/launchSettings.json b/examples/WireMock.Net.WebApplication.NETCore2/Properties/launchSettings.json similarity index 96% rename from examples/WireMock.Net.WebApplication/Properties/launchSettings.json rename to examples/WireMock.Net.WebApplication.NETCore2/Properties/launchSettings.json index fd7a2608..31f0369b 100644 --- a/examples/WireMock.Net.WebApplication/Properties/launchSettings.json +++ b/examples/WireMock.Net.WebApplication.NETCore2/Properties/launchSettings.json @@ -1,38 +1,38 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iis": { - "applicationUrl": "http://localhost//wiremock", - "sslPort": 0 - }, - "iisExpress": { - "applicationUrl": "http://localhost:56513/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchUrl": "__admin/settings", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "WireMock.Net.WebApplication": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "__admin/settings", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:56514/" - }, - "IIS": { - "commandName": "IIS", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "development" - } - } - } +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iis": { + "applicationUrl": "http://localhost//wiremock", + "sslPort": 0 + }, + "iisExpress": { + "applicationUrl": "http://localhost:56513/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchUrl": "__admin/settings", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WireMock.Net.WebApplication": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "__admin/settings", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:56514/" + }, + "IIS": { + "commandName": "IIS", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "development" + } + } + } } \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/WireMock.Net.WebApplication.NETCore2.csproj b/examples/WireMock.Net.WebApplication.NETCore2/WireMock.Net.WebApplication.NETCore2.csproj similarity index 100% rename from examples/WireMock.Net.WebApplication/WireMock.Net.WebApplication.NETCore2.csproj rename to examples/WireMock.Net.WebApplication.NETCore2/WireMock.Net.WebApplication.NETCore2.csproj diff --git a/examples/WireMock.Net.WebApplication/WireMockService.cs b/examples/WireMock.Net.WebApplication.NETCore2/WireMockService.cs similarity index 100% rename from examples/WireMock.Net.WebApplication/WireMockService.cs rename to examples/WireMock.Net.WebApplication.NETCore2/WireMockService.cs diff --git a/examples/WireMock.Net.WebApplication/appsettings.json b/examples/WireMock.Net.WebApplication.NETCore2/appsettings.json similarity index 100% rename from examples/WireMock.Net.WebApplication/appsettings.json rename to examples/WireMock.Net.WebApplication.NETCore2/appsettings.json diff --git a/examples/WireMock.Net.WebApplication/libman.json b/examples/WireMock.Net.WebApplication.NETCore2/libman.json similarity index 93% rename from examples/WireMock.Net.WebApplication/libman.json rename to examples/WireMock.Net.WebApplication.NETCore2/libman.json index ceee2710..b0b3b9a4 100644 --- a/examples/WireMock.Net.WebApplication/libman.json +++ b/examples/WireMock.Net.WebApplication.NETCore2/libman.json @@ -1,5 +1,5 @@ -{ - "version": "1.0", - "defaultProvider": "cdnjs", - "libraries": [] +{ + "version": "1.0", + "defaultProvider": "cdnjs", + "libraries": [] } \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/readme.md b/examples/WireMock.Net.WebApplication.NETCore2/readme.md similarity index 97% rename from examples/WireMock.Net.WebApplication/readme.md rename to examples/WireMock.Net.WebApplication.NETCore2/readme.md index 61d5b1a3..00ebec62 100644 --- a/examples/WireMock.Net.WebApplication/readme.md +++ b/examples/WireMock.Net.WebApplication.NETCore2/readme.md @@ -1,21 +1,21 @@ -# Running in IIS - -Follow these links / steps: -* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS -* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1 -* Create a `web.config` file - -## IIS Sites -![IIS Multiple](resources/iis-wiremock1and2.png) - -## App Pool settings -![IIS Multiple](resources/iis-apppool.png) - -## Publish Profiles -Two example publish profiles are created: -* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml) -* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml) - -## Debugging -Select the debug "IIS" if you want to debug in IIS. -![IIS Debug](resources/iis-debug.png) +# Running in IIS + +Follow these links / steps: +* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS +* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1 +* Create a `web.config` file + +## IIS Sites +![IIS Multiple](resources/iis-wiremock1and2.png) + +## App Pool settings +![IIS Multiple](resources/iis-apppool.png) + +## Publish Profiles +Two example publish profiles are created: +* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml) +* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml) + +## Debugging +Select the debug "IIS" if you want to debug in IIS. +![IIS Debug](resources/iis-debug.png) diff --git a/examples/WireMock.Net.WebApplication/resources/iis-apppool.png b/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-apppool.png similarity index 100% rename from examples/WireMock.Net.WebApplication/resources/iis-apppool.png rename to examples/WireMock.Net.WebApplication.NETCore2/resources/iis-apppool.png diff --git a/examples/WireMock.Net.WebApplication/resources/iis-debug.png b/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-debug.png similarity index 100% rename from examples/WireMock.Net.WebApplication/resources/iis-debug.png rename to examples/WireMock.Net.WebApplication.NETCore2/resources/iis-debug.png diff --git a/examples/WireMock.Net.WebApplication/resources/iis-wiremock1and2.png b/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-wiremock1and2.png similarity index 100% rename from examples/WireMock.Net.WebApplication/resources/iis-wiremock1and2.png rename to examples/WireMock.Net.WebApplication.NETCore2/resources/iis-wiremock1and2.png diff --git a/examples/WireMock.Net.WebApplication/web.config b/examples/WireMock.Net.WebApplication.NETCore2/web.config similarity index 95% rename from examples/WireMock.Net.WebApplication/web.config rename to examples/WireMock.Net.WebApplication.NETCore2/web.config index 37ed62c8..1f48560c 100644 --- a/examples/WireMock.Net.WebApplication/web.config +++ b/examples/WireMock.Net.WebApplication.NETCore2/web.config @@ -1,12 +1,12 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/App.cs b/examples/WireMock.Net.WebApplication.NETCore3/App.cs new file mode 100644 index 00000000..2575335b --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/App.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Logging; + +namespace WireMock.Net.WebApplication +{ + public class App + { + private readonly IWireMockService _service; + private readonly ILogger _logger; + + public App(IWireMockService service, ILogger logger) + { + _service = service; + _logger = logger; + } + + public void Run() + { + _logger.LogInformation("WireMock.Net App running"); + _service.Run(); + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/IWireMockService.cs b/examples/WireMock.Net.WebApplication.NETCore3/IWireMockService.cs new file mode 100644 index 00000000..de3ac175 --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/IWireMockService.cs @@ -0,0 +1,7 @@ +namespace WireMock.Net.WebApplication +{ + public interface IWireMockService + { + void Run(); + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/Program.cs b/examples/WireMock.Net.WebApplication.NETCore3/Program.cs new file mode 100644 index 00000000..336c7e9d --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/Program.cs @@ -0,0 +1,59 @@ +using System; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using WireMock.Settings; +// using Microsoft.Extensions.Logging.Console; + +namespace WireMock.Net.WebApplication +{ + public class Program + { + public static void Main(string[] args) + { + // Create service collection + var serviceCollection = new ServiceCollection(); + ConfigureServices(serviceCollection); + + // Create service provider + var serviceProvider = serviceCollection.BuildServiceProvider(); + + // Run app + serviceProvider.GetService().Run(); + } + + private static void ConfigureServices(IServiceCollection serviceCollection) + { + // Build configuration + var configuration = new ConfigurationBuilder() + .SetBasePath(AppContext.BaseDirectory) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddEnvironmentVariables() // <-- this is needed to to override settings via the Azure Portal App Settings + .Build(); + + // Add LoggerFactory + var factory = new LoggerFactory(); + //var consoleLog = new ConsoleLoggerProvider(configuration.GetSection("Logging")); + serviceCollection.AddSingleton(factory + // .AddProvider(configuration.GetSection("Logging")) +// .AddDebug() + // .AddAzureWebAppDiagnostics() + ); + + serviceCollection.AddSingleton(factory.CreateLogger("WireMock.Net Logger")); + + // Add access to generic IConfigurationRoot + serviceCollection.AddSingleton(configuration); + + // Add access to WireMockServerSettings + var settings = configuration.GetSection("WireMockServerSettings").Get(); + serviceCollection.AddSingleton(settings); + + // Add services + serviceCollection.AddTransient(); + + // Add app + serviceCollection.AddTransient(); + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/Properties/launchSettings.json b/examples/WireMock.Net.WebApplication.NETCore3/Properties/launchSettings.json new file mode 100644 index 00000000..31f0369b --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iis": { + "applicationUrl": "http://localhost//wiremock", + "sslPort": 0 + }, + "iisExpress": { + "applicationUrl": "http://localhost:56513/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchUrl": "__admin/settings", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WireMock.Net.WebApplication": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "__admin/settings", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:56514/" + }, + "IIS": { + "commandName": "IIS", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "development" + } + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/WireMock.Net.WebApplication.NETCore3.csproj b/examples/WireMock.Net.WebApplication.NETCore3/WireMock.Net.WebApplication.NETCore3.csproj new file mode 100644 index 00000000..fb52a5a5 --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/WireMock.Net.WebApplication.NETCore3.csproj @@ -0,0 +1,31 @@ + + + + netcoreapp3.1 + win10-x64 + WireMock.Net.WebApplication.Program + WireMock.Net.WebApplication + WireMock.Net.WebApplication + efcf4a18-fd7c-4622-1111-336d65290599 + + + + + + + + + + + + + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/WireMockService.cs b/examples/WireMock.Net.WebApplication.NETCore3/WireMockService.cs new file mode 100644 index 00000000..4aa28e14 --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/WireMockService.cs @@ -0,0 +1,83 @@ +using System; +using System.Threading; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using WireMock.Admin.Requests; +using WireMock.Logging; +using WireMock.Server; +using WireMock.Settings; + +namespace WireMock.Net.WebApplication +{ + public class WireMockService : IWireMockService + { + private static int sleepTime = 30000; + + private readonly ILogger _logger; + private readonly WireMockServerSettings _settings; + + private class Logger : IWireMockLogger + { + private readonly ILogger _logger; + + public Logger(ILogger logger) + { + _logger = logger; + } + + public void Debug(string formatString, params object[] args) + { + _logger.LogDebug(formatString, args); + } + + public void Info(string formatString, params object[] args) + { + _logger.LogInformation(formatString, args); + } + + public void Warn(string formatString, params object[] args) + { + _logger.LogWarning(formatString, args); + } + + public void Error(string formatString, params object[] args) + { + _logger.LogError(formatString, args); + } + + public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminrequest) + { + string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented); + _logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message); + } + + public void Error(string formatString, Exception exception) + { + _logger.LogError(formatString, exception.Message); + } + } + + public WireMockService(ILogger logger, WireMockServerSettings settings) + { + _logger = logger; + _settings = settings; + + _settings.Logger = new Logger(logger); + } + + public void Run() + { + _logger.LogInformation("WireMock.Net server starting"); + + WireMockServer.Start(_settings); + + _logger.LogInformation($"WireMock.Net server settings {JsonConvert.SerializeObject(_settings)}"); + + while (true) + { + _logger.LogInformation("WireMock.Net server running"); + Thread.Sleep(sleepTime); + } + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/appsettings.json b/examples/WireMock.Net.WebApplication.NETCore3/appsettings.json new file mode 100644 index 00000000..4b33bb6a --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/appsettings.json @@ -0,0 +1,20 @@ +{ + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Debug" + } + }, + "Console": { + "LogLevel": { + "Default": "Debug" + } + } + }, + "WireMockServerSettings": { + "AdminUsername": "a", + "AdminPassword": "b", + "StartAdminInterface": true + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore3/readme.md b/examples/WireMock.Net.WebApplication.NETCore3/readme.md new file mode 100644 index 00000000..00ebec62 --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/readme.md @@ -0,0 +1,21 @@ +# Running in IIS + +Follow these links / steps: +* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS +* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1 +* Create a `web.config` file + +## IIS Sites +![IIS Multiple](resources/iis-wiremock1and2.png) + +## App Pool settings +![IIS Multiple](resources/iis-apppool.png) + +## Publish Profiles +Two example publish profiles are created: +* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml) +* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml) + +## Debugging +Select the debug "IIS" if you want to debug in IIS. +![IIS Debug](resources/iis-debug.png) diff --git a/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-apppool.png b/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-apppool.png new file mode 100644 index 00000000..119df195 Binary files /dev/null and b/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-apppool.png differ diff --git a/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-debug.png b/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-debug.png new file mode 100644 index 00000000..0aa1936f Binary files /dev/null and b/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-debug.png differ diff --git a/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-wiremock1and2.png b/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-wiremock1and2.png new file mode 100644 index 00000000..6d50b12d Binary files /dev/null and b/examples/WireMock.Net.WebApplication.NETCore3/resources/iis-wiremock1and2.png differ diff --git a/examples/WireMock.Net.WebApplication.NETCore3/web.config b/examples/WireMock.Net.WebApplication.NETCore3/web.config new file mode 100644 index 00000000..ed25ab6d --- /dev/null +++ b/examples/WireMock.Net.WebApplication.NETCore3/web.config @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/Properties/PublishProfiles/IIS Localhost 1.pubxml b/examples/WireMock.Net.WebApplication/Properties/PublishProfiles/IIS Localhost 1.pubxml deleted file mode 100644 index df22ade6..00000000 --- a/examples/WireMock.Net.WebApplication/Properties/PublishProfiles/IIS Localhost 1.pubxml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - MSDeploy - Debug - Any CPU - - True - False - netcoreapp2.0 - win10-x64 - 049539c1-7a66-4559-ad7a-b1c73b97cbb0 - true - <_IsPortable>false - localhost - Default Web Site/wiremock1 - - True - InProc - False - - <_SavePWD>False - - - - - \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/Properties/PublishProfiles/IIS Localhost 2.pubxml b/examples/WireMock.Net.WebApplication/Properties/PublishProfiles/IIS Localhost 2.pubxml deleted file mode 100644 index e011abc5..00000000 --- a/examples/WireMock.Net.WebApplication/Properties/PublishProfiles/IIS Localhost 2.pubxml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - MSDeploy - Debug - Any CPU - - True - False - netcoreapp2.0 - win10-x64 - 049539c1-7a66-4559-ad7a-b1c73b97cbb1 - true - <_IsPortable>false - localhost - Default Web Site/wiremock2 - - True - InProc - False - - <_SavePWD>False - - - - - \ No newline at end of file