diff --git a/WireMock.Net Solution.sln b/WireMock.Net Solution.sln index 193b21e2..d872596f 100644 --- a/WireMock.Net Solution.sln +++ b/WireMock.Net Solution.sln @@ -98,6 +98,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Org.RestClient", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Org.Abstractions", "src\WireMock.Org.Abstractions\WireMock.Org.Abstractions.csproj", "{3BA5109E-5F30-4CC2-B699-02EC82560AA6}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET6", "examples\WireMock.Net.Console.NET6\WireMock.Net.Console.NET6.csproj", "{2215055B-594E-4C2F-99B2-6DF337F02893}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -228,6 +230,10 @@ Global {3BA5109E-5F30-4CC2-B699-02EC82560AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BA5109E-5F30-4CC2-B699-02EC82560AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU {3BA5109E-5F30-4CC2-B699-02EC82560AA6}.Release|Any CPU.Build.0 = Release|Any CPU + {2215055B-594E-4C2F-99B2-6DF337F02893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2215055B-594E-4C2F-99B2-6DF337F02893}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2215055B-594E-4C2F-99B2-6DF337F02893}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2215055B-594E-4C2F-99B2-6DF337F02893}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -266,6 +272,7 @@ Global {5B64F6CA-BF6B-4F67-BB2A-9C47E441703E} = {7EFB2C5B-1BB2-4AAF-BC9F-216ED80C594D} {08B29DB1-FEFE-408A-AD0A-6BA6DDC8D70F} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} {3BA5109E-5F30-4CC2-B699-02EC82560AA6} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} + {2215055B-594E-4C2F-99B2-6DF337F02893} = {985E0ADB-D4B4-473A-AA40-567E279B7946} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458} diff --git a/azure-pipelines-ci-linux.yml b/azure-pipelines-ci-linux.yml index f2e5ef09..44136841 100644 --- a/azure-pipelines-ci-linux.yml +++ b/azure-pipelines-ci-linux.yml @@ -6,7 +6,7 @@ variables: steps: - script: | - dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework netcoreapp3.1 --logger trx + dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework net6.0 --logger trx - task: PublishTestResults@2 inputs: testRunner: VSTest diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml index 9aab3219..ee82c460 100644 --- a/azure-pipelines-ci.yml +++ b/azure-pipelines-ci.yml @@ -35,21 +35,21 @@ jobs: projectKey: 'WireMock-Net_WireMock.Net' projectName: 'WireMock.Net' extraProperties: | - sonar.cs.opencover.reportsPaths=**/coverage.netcoreapp3.1.opencover.xml + sonar.cs.opencover.reportsPaths=**/coverage.net6.0.opencover.xml - task: DotNetCoreCLI@2 displayName: 'Build Unit tests' inputs: command: 'build' projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' - arguments: '--configuration Debug --framework netcoreapp3.1' + arguments: '--configuration Debug --framework net6.0' - task: DotNetCoreCLI@2 displayName: 'Execute Unit tests' inputs: command: 'test' projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' - arguments: '--no-build --configuration Debug --framework netcoreapp3.1 --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover' + arguments: '--no-build --configuration Debug --framework net6.0 --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover' - task: SonarCloudAnalyze@1 displayName: 'SonarCloud: Run Code Analysis' @@ -64,7 +64,7 @@ jobs: condition: and(succeeded(), eq(variables['RUN_WHITESOURCE'], 'yes')) - script: | - bash <(curl https://codecov.io/bash) -t $(CODECOV_TOKEN) -f ./test/WireMock.Net.Tests/coverage.netcoreapp3.1.opencover.xml + bash <(curl https://codecov.io/bash) -t $(CODECOV_TOKEN) -f ./test/WireMock.Net.Tests/coverage.net6.0.opencover.xml displayName: 'codecov' - task: PublishTestResults@2 @@ -76,13 +76,13 @@ jobs: - task: PublishBuildArtifacts@1 displayName: Publish coverage file inputs: - PathtoPublish: '/home/vsts/work/1/s/test/WireMock.Net.Tests/coverage.netcoreapp3.1.opencover.xml' + PathtoPublish: '/home/vsts/work/1/s/test/WireMock.Net.Tests/coverage.net6.0.opencover.xml' - job: Windows_Build_Test dependsOn: Linux_Build_Test_SonarCloud pool: - vmImage: 'windows-2019' + vmImage: 'windows-2022' steps: - task: DotNetCoreCLI@2 @@ -90,20 +90,20 @@ jobs: inputs: command: 'build' projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' - arguments: '--configuration Debug --framework netcoreapp3.1' + arguments: '--configuration Debug --framework net6.0' - task: DotNetCoreCLI@2 displayName: 'Execute Unit tests' inputs: command: 'test' projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' - arguments: '--no-build --configuration Debug --framework netcoreapp3.1 --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover' + arguments: '--no-build --configuration Debug --framework net6.0 --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover' - job: Windows_Release_to_MyGet dependsOn: Windows_Build_Test pool: - vmImage: 'windows-2019' + vmImage: 'windows-2022' steps: - task: DotNetCoreCLI@2 diff --git a/azure-pipelines-linux.yml b/azure-pipelines-linux.yml index b6ba683b..ee7a9a42 100644 --- a/azure-pipelines-linux.yml +++ b/azure-pipelines-linux.yml @@ -2,7 +2,7 @@ trigger: - none pool: - vmImage: 'Ubuntu 16.04' + vmImage: 'Ubuntu-latest' variables: buildProjects: '**/src/**/*.csproj' diff --git a/azure-pipelines-nuget.yml b/azure-pipelines-nuget.yml index 49707bd5..19ed91c3 100644 --- a/azure-pipelines-nuget.yml +++ b/azure-pipelines-nuget.yml @@ -1,5 +1,5 @@ pool: - vmImage: 'windows-2019' + vmImage: 'windows-2022' variables: Prerelease: '' diff --git a/examples/WireMock.Net.Client/Program.cs b/examples/WireMock.Net.Client/Program.cs index b478b71d..6d1f7224 100644 --- a/examples/WireMock.Net.Client/Program.cs +++ b/examples/WireMock.Net.Client/Program.cs @@ -1,9 +1,10 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using RestEase; using System; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; +using WireMock.Admin.Settings; using WireMock.Client; namespace WireMock.Net.Client @@ -22,7 +23,7 @@ namespace WireMock.Net.Client var settings1 = await api.GetSettingsAsync(); Console.WriteLine($"settings1 = {JsonConvert.SerializeObject(settings1)}"); - var settingsViaBuilder = new FluentBuilder.SettingsModelBuilder() + var settingsViaBuilder = new SettingsModelBuilder() .WithGlobalProcessingDelay(1077) .WithoutGlobalProcessingDelay() .Build(); diff --git a/examples/WireMock.Net.Client/WireMock.Net.Client.csproj b/examples/WireMock.Net.Client/WireMock.Net.Client.csproj index 3482a8ff..79e23257 100644 --- a/examples/WireMock.Net.Client/WireMock.Net.Client.csproj +++ b/examples/WireMock.Net.Client/WireMock.Net.Client.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp2.1 + net6.0 ../../resources/WireMock.Net-Logo.ico diff --git a/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj b/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj index 593c3c69..9e2f97ad 100644 --- a/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj +++ b/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj @@ -29,7 +29,7 @@ - + diff --git a/examples/WireMock.Net.Console.NET5/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json b/examples/WireMock.Net.Console.NET5/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json index 99738c88..ec54f7a6 100644 --- a/examples/WireMock.Net.Console.NET5/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json +++ b/examples/WireMock.Net.Console.NET5/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json @@ -4,20 +4,10 @@ "Matchers": [ { "Name": "WildcardMatcher", - "Patterns": [ "/static/mapping", "/static/mapping2" ] + "Pattern": "/static/mapping", } ] }, - "Body": { - "Matcher": { - "Name": "JsonMatcher", - "Pattern": { - "post1": "value 1", - "post2": "value 2" - }, - "IgnoreCase": true - } - }, "Methods": [ "get", "post" diff --git a/examples/WireMock.Net.Console.NET5/log4net.config b/examples/WireMock.Net.Console.NET5/log4net.config new file mode 100644 index 00000000..feae9952 --- /dev/null +++ b/examples/WireMock.Net.Console.NET5/log4net.config @@ -0,0 +1,20 @@ + + + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/WireMock.Net.Console.NET6.csproj b/examples/WireMock.Net.Console.NET6/WireMock.Net.Console.NET6.csproj new file mode 100644 index 00000000..0d2beed2 --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/WireMock.Net.Console.NET6.csproj @@ -0,0 +1,54 @@ + + + + Exe + net6.0 + + + + + + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + Never + + + PreserveNewest + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/__admin/mappings/1.cs b/examples/WireMock.Net.Console.NET6/__admin/mappings/1.cs new file mode 100644 index 00000000..c8143e09 --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/__admin/mappings/1.cs @@ -0,0 +1 @@ +// C# Hello \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json b/examples/WireMock.Net.Console.NET6/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json new file mode 100644 index 00000000..ec54f7a6 --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json @@ -0,0 +1,23 @@ +{ + "Request": { + "Path": { + "Matchers": [ + { + "Name": "WildcardMatcher", + "Pattern": "/static/mapping", + } + ] + }, + "Methods": [ + "get", + "post" + ] + }, + "Response": { + "BodyAsJson": { "body": "static mapping" }, + "Headers": { + "Content-Type": "application/json", + "Test-X": [ "test 1", "test 2" ] + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/__admin/mappings/791a3f31-6946-4ce7-8e6f-0237c7443275.json b/examples/WireMock.Net.Console.NET6/__admin/mappings/791a3f31-6946-4ce7-8e6f-0237c7443275.json new file mode 100644 index 00000000..d7a6cbdd --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/__admin/mappings/791a3f31-6946-4ce7-8e6f-0237c7443275.json @@ -0,0 +1,29 @@ +{ + "Guid": "791a3f31-6946-4ce7-8e6f-0237c7443275", + "Title": "", + "Priority": 0, + "Request": { + "Path": "/proxy-google-test-post", + "Methods": [ + "post" + ], + "Body": {} + }, + "Response": { + "StatusCode": 404, + "Body": "\n\n \n \n Error 404 (Not Found)!!1\n \n \n

404. That’s an error.\n

The requested URL /proxy-google-test-post was not found on this server. That’s all we know.\n", + "BodyAsBytes": "PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ZW4+CiAgPG1ldGEgY2hhcnNldD11dGYtOD4KICA8bWV0YSBuYW1lPXZpZXdwb3J0IGNvbnRlbnQ9ImluaXRpYWwtc2NhbGU9MSwgbWluaW11bS1zY2FsZT0xLCB3aWR0aD1kZXZpY2Utd2lkdGgiPgogIDx0aXRsZT5FcnJvciA0MDQgKE5vdCBGb3VuZCkhITE8L3RpdGxlPgogIDxzdHlsZT4KICAgICp7bWFyZ2luOjA7cGFkZGluZzowfWh0bWwsY29kZXtmb250OjE1cHgvMjJweCBhcmlhbCxzYW5zLXNlcmlmfWh0bWx7YmFja2dyb3VuZDojZmZmO2NvbG9yOiMyMjI7cGFkZGluZzoxNXB4fWJvZHl7bWFyZ2luOjclIGF1dG8gMDttYXgtd2lkdGg6MzkwcHg7bWluLWhlaWdodDoxODBweDtwYWRkaW5nOjMwcHggMCAxNXB4fSogPiBib2R5e2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2Vycm9ycy9yb2JvdC5wbmcpIDEwMCUgNXB4IG5vLXJlcGVhdDtwYWRkaW5nLXJpZ2h0OjIwNXB4fXB7bWFyZ2luOjExcHggMCAyMnB4O292ZXJmbG93OmhpZGRlbn1pbnN7Y29sb3I6Izc3Nzt0ZXh0LWRlY29yYXRpb246bm9uZX1hIGltZ3tib3JkZXI6MH1AbWVkaWEgc2NyZWVuIGFuZCAobWF4LXdpZHRoOjc3MnB4KXtib2R5e2JhY2tncm91bmQ6bm9uZTttYXJnaW4tdG9wOjA7bWF4LXdpZHRoOm5vbmU7cGFkZGluZy1yaWdodDowfX0jbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzF4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7bWFyZ2luLWxlZnQ6LTVweH1AbWVkaWEgb25seSBzY3JlZW4gYW5kIChtaW4tcmVzb2x1dGlvbjoxOTJkcGkpeyNsb2dve2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIG5vLXJlcGVhdCAwJSAwJS8xMDAlIDEwMCU7LW1vei1ib3JkZXItaW1hZ2U6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIDB9fUBtZWRpYSBvbmx5IHNjcmVlbiBhbmQgKC13ZWJraXQtbWluLWRldmljZS1waXhlbC1yYXRpbzoyKXsjbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzJ4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7LXdlYmtpdC1iYWNrZ3JvdW5kLXNpemU6MTAwJSAxMDAlfX0jbG9nb3tkaXNwbGF5OmlubGluZS1ibG9jaztoZWlnaHQ6NTRweDt3aWR0aDoxNTBweH0KICA8L3N0eWxlPgogIDxhIGhyZWY9Ly93d3cuZ29vZ2xlLmNvbS8+PHNwYW4gaWQ9bG9nbyBhcmlhLWxhYmVsPUdvb2dsZT48L3NwYW4+PC9hPgogIDxwPjxiPjQwNC48L2I+IDxpbnM+VGhhdOKAmXMgYW4gZXJyb3IuPC9pbnM+CiAgPHA+VGhlIHJlcXVlc3RlZCBVUkwgPGNvZGU+L3Byb3h5LWdvb2dsZS10ZXN0LXBvc3Q8L2NvZGU+IHdhcyBub3QgZm91bmQgb24gdGhpcyBzZXJ2ZXIuICA8aW5zPlRoYXTigJlzIGFsbCB3ZSBrbm93LjwvaW5zPgo=", + "BodyEncoding": { + "CodePage": 65001, + "EncodingName": "Unicode (UTF-8)", + "WebName": "utf-8" + }, + "UseTransformer": false, + "Headers": { + "Date": "Wed, 27 Oct 2017 18:57:40 GMT", + "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"39,38,37,35\"", + "Referrer-Policy": "no-referrer", + "Connection": "close" + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/__admin/mappings/873d495f-940e-4b86-a1f4-4f0fc7be8b8b.json b/examples/WireMock.Net.Console.NET6/__admin/mappings/873d495f-940e-4b86-a1f4-4f0fc7be8b8b.json new file mode 100644 index 00000000..dd501800 --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/__admin/mappings/873d495f-940e-4b86-a1f4-4f0fc7be8b8b.json @@ -0,0 +1,19 @@ +{ + "Guid": "873d495f-940e-4b86-a1f4-4f0fc7be8b8b", + "Priority": 4, + "Request": { + "Path": {}, + "Methods": [ + "get" + ] + }, + "Response": { + "StatusCode": 200, + "BodyDestination": "SameAsSource", + "Body": "NO PATH OR URL", + "UseTransformer": false, + "Headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/__admin/mappings/BodyAsFileExample.json b/examples/WireMock.Net.Console.NET6/__admin/mappings/BodyAsFileExample.json new file mode 100644 index 00000000..222f988b --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/__admin/mappings/BodyAsFileExample.json @@ -0,0 +1,23 @@ +{ + "Guid": "1234567A-940e-4b86-a1f4-4f0fc7be8b8b", + "Request": { + "Path": { + "Matchers": [ + { + "Name": "WildcardMatcher", + "Pattern": "/bodyasfilexmltest", + "IgnoreCase": false + } + ] + }, + "Methods": [ + "get" + ] + }, + "Response": { + "StatusCode": 200, + "Headers": { "Content-Type": "application/xml" }, + "BodyAsFile": "MyXmlResponse.xml", + "UseTransformer": false + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/__admin/mappings/MyXmlResponse.xml b/examples/WireMock.Net.Console.NET6/__admin/mappings/MyXmlResponse.xml new file mode 100644 index 00000000..24fd28d3 --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/__admin/mappings/MyXmlResponse.xml @@ -0,0 +1,3 @@ + +world + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/__admin/mappings/array.json b/examples/WireMock.Net.Console.NET6/__admin/mappings/array.json new file mode 100644 index 00000000..79f338ae --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/__admin/mappings/array.json @@ -0,0 +1,46 @@ +[ + { + "Title": "1", + "Request": { + "Path": { + "Matchers": [ + { + "Name": "WildcardMatcher", + "Pattern": "/mappings_static_1" + } + ] + }, + "Methods": [ + "get" + ] + }, + "Response": { + "BodyAsJson": { "result": "mappings static_1" }, + "Headers": { + "Content-Type": "application/json" + } + } + }, + { + "Title": "2", + "Request": { + "Path": { + "Matchers": [ + { + "Name": "WildcardMatcher", + "Pattern": "/mappings_static_2" + } + ] + }, + "Methods": [ + "get" + ] + }, + "Response": { + "BodyAsJson": { "result": "mappings static_2" }, + "Headers": { + "Content-Type": "application/json" + } + } + } +] \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NET6/log4net.config b/examples/WireMock.Net.Console.NET6/log4net.config new file mode 100644 index 00000000..feae9952 --- /dev/null +++ b/examples/WireMock.Net.Console.NET6/log4net.config @@ -0,0 +1,20 @@ + + + +

+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj index 70439a56..626fcd9a 100644 --- a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj @@ -25,7 +25,7 @@ - + diff --git a/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj b/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj index 1757b09b..0b5f2f20 100644 --- a/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj @@ -34,7 +34,7 @@ - + diff --git a/examples/WireMock.Net.Console.NETCoreApp3/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json b/examples/WireMock.Net.Console.NETCoreApp3/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json index 9c761369..20565d64 100644 --- a/examples/WireMock.Net.Console.NETCoreApp3/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json +++ b/examples/WireMock.Net.Console.NETCoreApp3/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json @@ -13,7 +13,7 @@ ] }, "Response": { - "BodyAsJson": { "body": "static mapping" }, + "BodyAsJson": { "body": "static mapping1" }, "Headers": { "Content-Type": "application/json", "Test-X": [ "test 1", "test 2" ] diff --git a/examples/WireMock.Net.Console.Net452.Classic/App.config b/examples/WireMock.Net.Console.Net452.Classic/App.config index 2394ca3f..fe112f0c 100644 --- a/examples/WireMock.Net.Console.Net452.Classic/App.config +++ b/examples/WireMock.Net.Console.Net452.Classic/App.config @@ -7,7 +7,11 @@ - + + + + + diff --git a/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs b/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs index 5fa993c5..0104993b 100644 --- a/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs +++ b/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs @@ -459,6 +459,15 @@ namespace WireMock.Net.ConsoleApplication .WithBody("linq match !!!") ); + server + .Given(Request.Create().WithPath("/linq2") + .WithBody(new LinqMatcher("it.applicationId != null")) + .UsingPost() + ) + .RespondWith(Response.Create() + .WithBody("linq2 match !!!") + ); + server .Given(Request.Create().WithPath("/myendpoint").UsingAnyMethod()) .RespondWith(Response.Create() diff --git a/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj b/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj index f7877fdb..f283d8ff 100644 --- a/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj +++ b/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj @@ -36,20 +36,20 @@ ..\..\resources\WireMock.Net-Logo.ico - - ..\..\packages\AnyOf.0.2.0\lib\net45\AnyOf.dll + + ..\..\packages\AnyOf.0.3.0\lib\net45\AnyOf.dll - - ..\..\packages\Handlebars.Net.2.0.4\lib\net452\Handlebars.dll + + ..\..\packages\Handlebars.Net.2.1.0\lib\net452\Handlebars.dll - - ..\..\packages\Handlebars.Net.Helpers.2.1.1-preview-01\lib\net452\Handlebars.Net.Helpers.dll + + ..\..\packages\Handlebars.Net.Helpers.2.3.2\lib\net452\Handlebars.Net.Helpers.dll - - ..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll + + ..\..\packages\Handlebars.Net.Helpers.Core.2.3.3\lib\net452\HandlebarsDotNet.Helpers.Core.dll - - ..\..\packages\log4net.2.0.13\lib\net45\log4net.dll + + ..\..\packages\log4net.2.0.14\lib\net45\log4net.dll @@ -64,8 +64,8 @@ - - ..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + + ..\..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll @@ -80,6 +80,7 @@ Designer + PreserveNewest diff --git a/examples/WireMock.Net.Console.Net452.Classic/packages.config b/examples/WireMock.Net.Console.Net452.Classic/packages.config index cea3a614..c3db5700 100644 --- a/examples/WireMock.Net.Console.Net452.Classic/packages.config +++ b/examples/WireMock.Net.Console.Net452.Classic/packages.config @@ -1,12 +1,12 @@  - - - - - + + + + + - + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Net461.Classic/App.config b/examples/WireMock.Net.Console.Net461.Classic/App.config index 731f6de6..8569ad97 100644 --- a/examples/WireMock.Net.Console.Net461.Classic/App.config +++ b/examples/WireMock.Net.Console.Net461.Classic/App.config @@ -1,6 +1,18 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj b/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj index b29e4207..dacaab26 100644 --- a/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj +++ b/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj @@ -35,17 +35,17 @@ WireMock.Net.ConsoleApplication.Program - - ..\..\packages\AnyOf.0.2.0\lib\net45\AnyOf.dll + + ..\..\packages\AnyOf.0.3.0\lib\net45\AnyOf.dll - - ..\..\packages\Handlebars.Net.2.0.4\lib\net46\Handlebars.dll + + ..\..\packages\Handlebars.Net.2.1.0\lib\net46\Handlebars.dll - - ..\..\packages\Handlebars.Net.Helpers.2.1.1-preview-01\lib\net452\Handlebars.Net.Helpers.dll + + ..\..\packages\Handlebars.Net.Helpers.2.3.1\lib\net452\Handlebars.Net.Helpers.dll - - ..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll + + ..\..\packages\Handlebars.Net.Helpers.Core.2.3.3\lib\net452\HandlebarsDotNet.Helpers.Core.dll ..\..\packages\log4net.2.0.13\lib\net45\log4net.dll @@ -62,8 +62,8 @@ - - ..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + + ..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll diff --git a/examples/WireMock.Net.Console.Net461.Classic/packages.config b/examples/WireMock.Net.Console.Net461.Classic/packages.config index 4dda0468..3d8988a6 100644 --- a/examples/WireMock.Net.Console.Net461.Classic/packages.config +++ b/examples/WireMock.Net.Console.Net461.Classic/packages.config @@ -1,12 +1,12 @@  - - - - + + + + - + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Net472.Classic/App.config b/examples/WireMock.Net.Console.Net472.Classic/App.config index 773045f8..5f605248 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/App.config +++ b/examples/WireMock.Net.Console.Net472.Classic/App.config @@ -49,6 +49,14 @@ + + + + + + + + diff --git a/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj b/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj index 32fee8c9..03870ecc 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj +++ b/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj @@ -39,20 +39,20 @@ WireMock.Net.ConsoleApplication.Program - - ..\..\packages\AnyOf.0.2.0\lib\net45\AnyOf.dll + + ..\..\packages\AnyOf.0.3.0\lib\net45\AnyOf.dll - ..\..\packages\Fare.2.1.1\lib\net35\Fare.dll + ..\..\packages\Fare.2.1.2\lib\net35\Fare.dll - - ..\..\packages\Handlebars.Net.2.0.4\lib\net46\Handlebars.dll + + ..\..\packages\Handlebars.Net.2.1.0\lib\net46\Handlebars.dll - - ..\..\packages\Handlebars.Net.Helpers.2.1.1-preview-01\lib\net452\Handlebars.Net.Helpers.dll + + ..\..\packages\Handlebars.Net.Helpers.2.3.2\lib\net452\Handlebars.Net.Helpers.dll - - ..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll + + ..\..\packages\Handlebars.Net.Helpers.Core.2.3.3\lib\net452\HandlebarsDotNet.Helpers.Core.dll ..\..\packages\JmesPath.Net.1.0.125\lib\net45\JmesPath.Net.dll @@ -241,8 +241,8 @@ ..\..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll - - ..\..\packages\System.Linq.Dynamic.Core.1.0.12\lib\net46\System.Linq.Dynamic.Core.dll + + ..\..\packages\System.Linq.Dynamic.Core.1.2.16\lib\net46\System.Linq.Dynamic.Core.dll ..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll diff --git a/examples/WireMock.Net.Console.Net472.Classic/packages.config b/examples/WireMock.Net.Console.Net472.Classic/packages.config index f325bc7a..fc582665 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/packages.config +++ b/examples/WireMock.Net.Console.Net472.Classic/packages.config @@ -1,10 +1,10 @@  - - - - - + + + + + @@ -67,7 +67,7 @@ - + diff --git a/examples/WireMock.Net.StandAlone.NETCoreApp/Program.cs b/examples/WireMock.Net.StandAlone.NETCoreApp/Program.cs index dfcdc81c..62ae3400 100644 --- a/examples/WireMock.Net.StandAlone.NETCoreApp/Program.cs +++ b/examples/WireMock.Net.StandAlone.NETCoreApp/Program.cs @@ -35,21 +35,21 @@ namespace WireMock.Net.StandAlone.NETCoreApp _server = WireMockServer.Start(settings); - _server.Given(Request.Create().WithPath("/api/sap") - .UsingPost() - .WithBody((IBodyData xmlData) => - { - //xmlData is always null - return true; - })) - .RespondWith(Response.Create().WithStatusCode(System.Net.HttpStatusCode.OK)); + //_server.Given(Request.Create().WithPath("/api/sap") + // .UsingPost() + // .WithBody((IBodyData xmlData) => + // { + // //xmlData is always null + // return true; + // })) + // .RespondWith(Response.Create().WithStatusCode(System.Net.HttpStatusCode.OK)); - _server - .Given(Request.Create() - .UsingAnyMethod()) - .RespondWith(Response.Create() - .WithTransformer() - .WithBody("{{Random Type=\"Integer\" Min=100 Max=999999}} {{DateTime.Now}} {{DateTime.Now \"yyyy-MMM\"}} {{String.Format (DateTime.Now) \"MMM-dd\"}}")); + //_server + // .Given(Request.Create() + // .UsingAnyMethod()) + // .RespondWith(Response.Create() + // .WithTransformer() + // .WithBody("{{Random Type=\"Integer\" Min=100 Max=999999}} {{DateTime.Now}} {{DateTime.Now \"yyyy-MMM\"}} {{String.Format (DateTime.Now) \"MMM-dd\"}}")); Console.WriteLine($"{DateTime.UtcNow} Press Ctrl+C to shut down"); diff --git a/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj b/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj index c667c1cf..f4adcaef 100644 --- a/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj +++ b/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj @@ -225,8 +225,8 @@ ..\..\packages\System.IO.Pipelines.4.5.2\lib\netstandard2.0\System.IO.Pipelines.dll - - ..\..\packages\System.Linq.Dynamic.Core.1.0.12\lib\net46\System.Linq.Dynamic.Core.dll + + ..\..\packages\System.Linq.Dynamic.Core.1.2.16\lib\net46\System.Linq.Dynamic.Core.dll ..\..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll diff --git a/examples/WireMock.Net.StandAlone.Net461/packages.config b/examples/WireMock.Net.StandAlone.Net461/packages.config index 5a7028ba..d51deb61 100644 --- a/examples/WireMock.Net.StandAlone.Net461/packages.config +++ b/examples/WireMock.Net.StandAlone.Net461/packages.config @@ -65,7 +65,7 @@ - + diff --git a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj index 0066314e..ee407216 100644 --- a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj +++ b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj @@ -32,10 +32,10 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj b/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj index 5daa4b4c..1e917f4a 100644 --- a/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj +++ b/src/WireMock.Net.FluentAssertions/WireMock.Net.FluentAssertions.csproj @@ -38,7 +38,7 @@ - + diff --git a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs index 5fd1c600..9173b93a 100644 --- a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs +++ b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs @@ -155,7 +155,7 @@ namespace WireMock.Matchers throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex); } -#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0) +#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0 || NET6_0) Assembly assembly; try { @@ -169,11 +169,11 @@ namespace WireMock.Matchers dynamic script; try { -#if NETSTANDARD2_0 - script = csscript.GenericExtensions.CreateObject(assembly, "*"); -#else - script = CSScriptLib.ReflectionExtensions.CreateObject(assembly, "*"); -#endif +//#if NETSTANDARD2_0 +// script = csscript.GenericExtensions.CreateObject(assembly, "*"); +//#else + script = CSScripting.ReflectionExtensions.CreateObject(assembly, "*"); +//#endif } catch (Exception ex) { diff --git a/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj b/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj index e7e6b03c..6920efa6 100644 --- a/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj +++ b/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj @@ -1,10 +1,10 @@ - + A CSharpCodeMatcher which can be used to match WireMock.Net Requests using C# code. WireMock.Net.Matchers.CSharpCode Stef Heyenrath - net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0 + net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0 true wiremock;matchers;matcher;csharp;csharpcode WireMock @@ -32,7 +32,7 @@ - + @@ -45,16 +45,8 @@ - - - - - - - - - - + + \ No newline at end of file diff --git a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj index c9452908..8244c55d 100644 --- a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj +++ b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj @@ -1,4 +1,4 @@ - + An OpenApi (swagger) parser to generate MappingModel or mapping.json file. @@ -22,7 +22,7 @@ - + diff --git a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj index 732f4c42..68c57863 100644 --- a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj +++ b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj index 8955831e..6513ba10 100644 --- a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj +++ b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj @@ -1,9 +1,9 @@ - + Lightweight StandAlone Http Mocking Server for .Net. WireMock.Net.StandAlone Stef Heyenrath - net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0 + net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0 true WireMock.Net.StandAlone WireMock.Net.StandAlone diff --git a/src/WireMock.Net/Http/HttpClientBuilder.cs b/src/WireMock.Net/Http/HttpClientBuilder.cs index 67dbebf1..3b72e305 100644 --- a/src/WireMock.Net/Http/HttpClientBuilder.cs +++ b/src/WireMock.Net/Http/HttpClientBuilder.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using System.Net.Http; using WireMock.HttpsCertificate; using WireMock.Settings; @@ -9,7 +9,7 @@ namespace WireMock.Http { public static HttpClient Build(IHttpClientSettings settings) { -#if NETSTANDARD || NETCOREAPP3_1 || NET5_0 +#if NETSTANDARD || NETCOREAPP3_1 || NET5_0 || NET6_0 var handler = new HttpClientHandler { CheckCertificateRevocationList = false, diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs index 4076ea2f..3c505e16 100644 --- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs +++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1_OR_GREATER +#if NETCOREAPP3_1 || NET5_0 || NET6_0 using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using WireMock.Types; diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs index 9cfef009..097a2159 100644 --- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs +++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs @@ -70,7 +70,7 @@ namespace WireMock.Owin services.AddSingleton(); services.AddSingleton(); -#if NETCOREAPP3_1_OR_GREATER +#if NETCOREAPP3_1 || NET5_0 || NET6_0 AddCors(services); #endif _wireMockMiddlewareOptions.AdditionalServiceRegistration?.Invoke(services); @@ -79,7 +79,7 @@ namespace WireMock.Owin { appBuilder.UseMiddleware(); -#if NETCOREAPP3_1_OR_GREATER +#if NETCOREAPP3_1 || NET5_0 || NET6_0 UseCors(appBuilder); #endif _wireMockMiddlewareOptions.PreWireMockMiddlewareInit?.Invoke(appBuilder); @@ -136,6 +136,8 @@ namespace WireMock.Owin _logger.Info("Server using .NET Core 3.1"); #elif NET5_0 _logger.Info("Server using .NET 5.0"); +#elif NET6_0 + _logger.Info("Server using .NET 6.0"); #elif NET46 _logger.Info("Server using .NET Framework 4.6.1 or higher"); #endif diff --git a/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs index 216717d2..21a90f23 100644 --- a/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs +++ b/src/WireMock.Net/ResponseBuilders/IBodyResponseBuilder.cs @@ -1,74 +1,74 @@ -using JetBrains.Annotations; -using System; -using System.Text; +using JetBrains.Annotations; +using System; +using System.Text; using System.Threading.Tasks; -namespace WireMock.ResponseBuilders -{ - /// - /// The BodyResponseBuilder interface. - /// - public interface IBodyResponseBuilder : IFaultResponseBuilder - { - /// - /// WithBody : Create a ... response based on a string. - /// - /// The body. - /// The Body Destination format (SameAsSource, String or Bytes). - /// The body encoding. - /// A . - IResponseBuilder WithBody([NotNull] string body, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); - - /// - /// WithBody : Create a ... response based on a callback function. - /// - /// The delegate to build the body. - /// The Body Destination format (SameAsSource, String or Bytes). - /// The body encoding. - /// A . - IResponseBuilder WithBody([NotNull] Func bodyFactory, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); - - /// - /// WithBody : Create a ... response based on a callback function. - /// - /// The async delegate to build the body. - /// The Body Destination format (SameAsSource, String or Bytes). - /// The body encoding. - /// A . - IResponseBuilder WithBody([NotNull] Func> bodyFactory, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); - - /// - /// WithBody : Create a ... response based on a bytearray. - /// - /// The body. - /// The Body Destination format (SameAsSource, String or Bytes). - /// The body encoding. - /// A . - IResponseBuilder WithBody([NotNull] byte[] body, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); - - /// - /// WithBody : Create a string response based on a object (which will be converted to a JSON string). - /// - /// The body. - /// The body encoding. - /// Use JSON indented. - /// A . - IResponseBuilder WithBodyAsJson([NotNull] object body, [CanBeNull] Encoding encoding = null, bool? indented = null); - - /// - /// WithBody : Create a string response based on a object (which will be converted to a JSON string). - /// - /// The body. - /// Define whether child objects to be indented according to the Newtonsoft.Json.JsonTextWriter.Indentation and Newtonsoft.Json.JsonTextWriter.IndentChar settings. - /// A . - IResponseBuilder WithBodyAsJson([NotNull] object body, bool indented); - - /// - /// WithBodyFromFile : Create a ... response based on a File. - /// - /// The filename. - /// Defines if this file is cached in memory or retrieved from disk every time the response is created. - /// A . - IResponseBuilder WithBodyFromFile([NotNull] string filename, bool cache = true); - } +namespace WireMock.ResponseBuilders +{ + /// + /// The BodyResponseBuilder interface. + /// + public interface IBodyResponseBuilder : IFaultResponseBuilder + { + /// + /// WithBody : Create a ... response based on a string. + /// + /// The body. + /// The Body Destination format (SameAsSource, String or Bytes). + /// The body encoding. + /// A . + IResponseBuilder WithBody([NotNull] string body, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); + + /// + /// WithBody : Create a ... response based on a callback function. + /// + /// The delegate to build the body. + /// The Body Destination format (SameAsSource, String or Bytes). + /// The body encoding. + /// A . + IResponseBuilder WithBody([NotNull] Func bodyFactory, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); + + /// + /// WithBody : Create a ... response based on a callback function. + /// + /// The async delegate to build the body. + /// The Body Destination format (SameAsSource, String or Bytes). + /// The body encoding. + /// A . + IResponseBuilder WithBody([NotNull] Func> bodyFactory, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); + + /// + /// WithBody : Create a ... response based on a bytearray. + /// + /// The body. + /// The Body Destination format (SameAsSource, String or Bytes). + /// The body encoding. + /// A . + IResponseBuilder WithBody([NotNull] byte[] body, [CanBeNull] string destination = BodyDestinationFormat.SameAsSource, [CanBeNull] Encoding encoding = null); + + /// + /// WithBody : Create a string response based on a object (which will be converted to a JSON string). + /// + /// The body. + /// The body encoding. + /// Use JSON indented. + /// A . + IResponseBuilder WithBodyAsJson([NotNull] object body, [CanBeNull] Encoding encoding = null, bool? indented = null); + + /// + /// WithBody : Create a string response based on a object (which will be converted to a JSON string). + /// + /// The body. + /// Define whether child objects to be indented according to the Newtonsoft.Json.JsonTextWriter.Indentation and Newtonsoft.Json.JsonTextWriter.IndentChar settings. + /// A . + IResponseBuilder WithBodyAsJson([NotNull] object body, bool indented); + + /// + /// WithBodyFromFile : Create a ... response based on a File. + /// + /// The filename. + /// Defines if this file is cached in memory or retrieved from disk every time the response is created. + /// A . + IResponseBuilder WithBodyFromFile([NotNull] string filename, bool cache = true); + } } \ No newline at end of file diff --git a/src/WireMock.Net/Server/WireMockServer.Admin.cs b/src/WireMock.Net/Server/WireMockServer.Admin.cs index eef79485..44ecab2b 100644 --- a/src/WireMock.Net/Server/WireMockServer.Admin.cs +++ b/src/WireMock.Net/Server/WireMockServer.Admin.cs @@ -33,7 +33,7 @@ namespace WireMock.Server /// public partial class WireMockServer { - private const int EnhancedFileSystemWatcherTimeoutMs = 1000; + private const int EnhancedFileSystemWatcherTimeoutMs = 10000; // Changed from 1000 to 10000 (#726) private const int AdminPriority = int.MinValue; private const int ProxyPriority = 1000; private const string ContentTypeJson = "application/json"; diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 4331ecf3..eabbf1ab 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -3,7 +3,7 @@ Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape. WireMock.Net Stef Heyenrath - net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0 + net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0 true WireMock.Net WireMock.Net @@ -42,7 +42,7 @@ NETSTANDARD;USE_ASPNETCORE - + USE_ASPNETCORE @@ -50,16 +50,20 @@ USE_ASPNETCORE;NET46 + + + + - + - + - + @@ -72,7 +76,7 @@ - + @@ -100,6 +104,9 @@ + + + @@ -121,19 +128,19 @@ - + - - - - - - - + + + + + + + diff --git a/src/WireMock.Org.Abstractions/WireMock.Org.Abstractions.csproj b/src/WireMock.Org.Abstractions/WireMock.Org.Abstractions.csproj index d722898b..2269f681 100644 --- a/src/WireMock.Org.Abstractions/WireMock.Org.Abstractions.csproj +++ b/src/WireMock.Org.Abstractions/WireMock.Org.Abstractions.csproj @@ -1,14 +1,12 @@ - + Commonly used interfaces, models, enumerations and types. WireMock.Org.Abstractions Stef Heyenrath net45;netstandard1.0;netstandard2.0;netstandard2.1 - true $(NoWarn);1591;8603 - WireMock.Org.Abstractions WireMock.Org.Abstractions wiremock;wiremock.org;interfaces;models;classes;enumerations;types @@ -35,7 +33,7 @@ - + \ No newline at end of file diff --git a/src/dotnet-WireMock.Net/dotnet-WireMock.csproj b/src/dotnet-WireMock.Net/dotnet-WireMock.csproj index 35973450..e836f871 100644 --- a/src/dotnet-WireMock.Net/dotnet-WireMock.csproj +++ b/src/dotnet-WireMock.Net/dotnet-WireMock.csproj @@ -1,8 +1,8 @@ - + Exe - net5.0 + net6.0 true dotnet-wiremock A dotnet commandline tool for WireMock.Net (A Lightweight Http Mocking Server for .NET) @@ -16,8 +16,8 @@ - - + + diff --git a/test/WireMock.Net.Tests/Util/JsonUtilsTests.cs b/test/WireMock.Net.Tests/Util/JsonUtilsTests.cs index 29631f7a..a1ade309 100644 --- a/test/WireMock.Net.Tests/Util/JsonUtilsTests.cs +++ b/test/WireMock.Net.Tests/Util/JsonUtilsTests.cs @@ -1,8 +1,9 @@ -using System; +using System; using System.Linq; +using System.Linq.Dynamic.Core; +using FluentAssertions; using Newtonsoft.Json.Linq; using NFluent; -using System.Linq.Dynamic.Core; using WireMock.Util; using Xunit; @@ -41,7 +42,28 @@ namespace WireMock.Net.Tests.Util } [Fact] - public void JsonUtils_GenerateDynamicLinqStatement_JObject() + public void JsonUtils_GenerateDynamicLinqStatement_JArray_Indexer() + { + // Assign + var j = new JObject + { + { "Items", new JArray(new[] { new JValue(4), new JValue(8) }) } + }; + + // Act + string line = JsonUtils.GenerateDynamicLinqStatement(j); + + // Assert 1 + line.Should().Be("new ((new [] { long(Items[0]), long(Items[1])}) as Items)"); + + // Assert 2 + var queryable = new[] { j }.AsQueryable().Select(line); + bool result = queryable.Any("Items != null"); + result.Should().BeTrue(); + } + + [Fact] + public void JsonUtils_GenerateDynamicLinqStatement_JObject2() { // Assign var j = new JObject @@ -52,7 +74,6 @@ namespace WireMock.Net.Tests.Util {"Flt", new JValue(10.0f)}, {"Dbl", new JValue(Math.PI)}, {"Check", new JValue(true)}, - {"Items", new JArray(new[] { new JValue(4), new JValue(8) })}, { "Child", new JObject { @@ -69,12 +90,13 @@ namespace WireMock.Net.Tests.Util // Act string line = JsonUtils.GenerateDynamicLinqStatement(j); - // Assert + // Assert 1 + line.Should().Be("new (Uri(U) as U, null as N, Guid(G) as G, double(Flt) as Flt, double(Dbl) as Dbl, bool(Check) as Check, new (long(Child.ChildId) as ChildId, DateTime(Child.ChildDateTime) as ChildDateTime, TimeSpan(Child.TS) as TS) as Child, long(I) as I, long(L) as L, string(Name) as Name)"); + + // Assert 2 var queryable = new[] { j }.AsQueryable().Select(line); bool result = queryable.Any("I > 1 && L > 1"); - Check.That(result).IsTrue(); - - Check.That(line).IsEqualTo("new (Uri(U) as U, null as N, Guid(G) as G, double(Flt) as Flt, double(Dbl) as Dbl, bool(Check) as Check, (new [] { long(Items[0]), long(Items[1])}) as Items, new (long(Child.ChildId) as ChildId, DateTime(Child.ChildDateTime) as ChildDateTime, TimeSpan(Child.TS) as TS) as Child, long(I) as I, long(L) as L, string(Name) as Name)"); + result.Should().BeTrue(); } [Fact] diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index 113122f4..06c23692 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -2,7 +2,7 @@ Stef Heyenrath - net452;net461;netcoreapp3.1;net5.0 + net452;net461;netcoreapp3.1;net5.0;net6.0 false full WireMock.Net.Tests @@ -33,7 +33,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -44,7 +44,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -59,9 +59,9 @@ - + - + @@ -72,7 +72,7 @@ - + diff --git a/test/WireMock.Net.Tests/WireMockServerTests.cs b/test/WireMock.Net.Tests/WireMockServerTests.cs index d725478d..f5e0643f 100644 --- a/test/WireMock.Net.Tests/WireMockServerTests.cs +++ b/test/WireMock.Net.Tests/WireMockServerTests.cs @@ -98,7 +98,7 @@ namespace WireMock.Net.Tests server.Stop(); } -#if NETCOREAPP3_1_OR_GREATER +#if NETCOREAPP3_1 || NET5_0 || NET6_0 [Fact] public async Task WireMockServer_WithCorsPolicyOptions_Should_Work_Correct() {