Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping up interceptors, fixing typos, removing Moq #2141

Merged
merged 25 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d81d8ac
Wrapping up interceptors, fixing typos, removing Moq
alexeyzimarev Sep 14, 2023
b2500c2
Add Linux runner, and publish tests results from Linux
alexeyzimarev Sep 15, 2023
8fd9767
A bit of cleanup and adding package versions for source gen
alexeyzimarev Sep 15, 2023
121bf93
Add missing version
alexeyzimarev Sep 15, 2023
4a40bcd
Fixed centralized package versions
alexeyzimarev Sep 18, 2023
2bda7ee
Leave exception handling as it is
alexeyzimarev Oct 24, 2023
b582f59
Remove duplicate package version
alexeyzimarev Oct 24, 2023
95ed004
Cleanup
alexeyzimarev Apr 2, 2024
f6be96c
Merge branch 'refs/heads/dev' into wrapping-up-interceptors
alexeyzimarev Apr 2, 2024
78d7d0b
Fix the readme issue
alexeyzimarev Apr 2, 2024
74970c2
- Added compatibility interceptor
alexeyzimarev Apr 2, 2024
7d8f957
Add permissions to publish test results
alexeyzimarev Apr 2, 2024
56a1161
Refactoring tests to WireMock
alexeyzimarev Apr 3, 2024
3165eaf
Allow body for GET and HEAD in tests
alexeyzimarev Apr 3, 2024
3e09a51
Cleaning up fixtures
alexeyzimarev Apr 3, 2024
f7f689e
Fix the download test
alexeyzimarev Apr 3, 2024
1b11eb2
Disable NTML tests on Linux
alexeyzimarev Apr 3, 2024
8446276
Add matrix
alexeyzimarev Apr 3, 2024
8657a8b
Try running 472 too
alexeyzimarev Apr 3, 2024
251aee8
Refactoring tests
alexeyzimarev Apr 5, 2024
aac4921
Add .NET Framework 4.8 target
alexeyzimarev Apr 5, 2024
229550a
Add 4.8 to the matrix
alexeyzimarev Apr 5, 2024
51abdef
Fixing compilation
alexeyzimarev Apr 5, 2024
ce369ef
Content type fix
alexeyzimarev Apr 5, 2024
b80b25f
Disable non-ASCII upload test for .NET 6
alexeyzimarev Apr 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed centralized package versions
alexeyzimarev committed Sep 18, 2023
commit 4a40bcd585ff5dd944035753bd9b3df210253f19
4 changes: 4 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -34,5 +34,9 @@
<PackageVersion Include="BenchmarkDotNet" Version="0.13.8"/>
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0"/>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4"/>
<PackageVersion Include="Moq" Version="4.20.69"/>
<PackageVersion Include="RichardSzalay.MockHttp" Version="6.0.0"/>
<PackageVersion Include="System.Net.Http.Json" Version="7.0.1"/>
<PackageVersion Include="rest-mock-core" Version="0.7.12"/>
</ItemGroup>
</Project>
3 changes: 0 additions & 3 deletions gen/SourceGenerator/SourceGenerator.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
@@ -9,12 +8,10 @@
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\RestSharp.Serializers.NewtonsoftJson\RestSharp.Serializers.NewtonsoftJson.csproj" />
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj" />
<ProjectReference Include="..\RestSharp.Tests.Shared\RestSharp.Tests.Shared.csproj" />
<ProjectReference Include="$(RepoRoot)\src\RestSharp.Serializers.NewtonsoftJson\RestSharp.Serializers.NewtonsoftJson.csproj"/>
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj"/>
<ProjectReference Include="..\RestSharp.Tests.Shared\RestSharp.Tests.Shared.csproj"/>
</ItemGroup>
<ItemGroup>
<Compile Remove="NewtonsoftJson\IntegratedTests.cs" />
<Compile Remove="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="rest-mock-core" Version="0.7.12" />
<Compile Include="NewtonsoftJson\IntegratedTests.cs" />
<PackageReference Include="rest-mock-core"/>
<Compile Include="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="rest-mock-core" Version="0.7.12" />
<Compile Include="NewtonsoftJson\IntegratedTests.cs" />
<PackageReference Include="rest-mock-core"/>
<Compile Include="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="rest-mock-core"/>
<Compile Include="NewtonsoftJson\IntegratedTests.cs"/>
</ItemGroup>
</Project>
9 changes: 3 additions & 6 deletions test/RestSharp.Tests.Shared/Fixtures/TestHttpServer.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@

namespace RestSharp.Tests.Shared.Fixtures;

public delegate void HandlerAction(HttpListenerRequest request, HttpListenerResponse response, Dictionary<string, string> urlMap);

public class TestHttpServer : IDisposable {
readonly HttpListener _listener;
readonly List<TestRequestHandler> _requestHandlers;
@@ -12,12 +14,7 @@ public class TestHttpServer : IDisposable {

public int Port { get; }

public TestHttpServer(
int port,
string url,
Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> handlerAction,
string hostName = "localhost"
)
public TestHttpServer(int port, string url, HandlerAction handlerAction, string hostName = "localhost")
: this(port, new List<TestRequestHandler> { new(url, handlerAction) }, hostName) { }

public TestHttpServer(int port, List<TestRequestHandler> handlers, string hostName = "localhost") {
21 changes: 7 additions & 14 deletions test/RestSharp.Tests.Shared/Fixtures/TestRequestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Net;
using System.Text.RegularExpressions;

namespace RestSharp.Tests.Shared.Fixtures;
@@ -8,24 +7,19 @@ public class TestRequestHandler {

readonly List<string> _urlParameterNames = new();

public TestRequestHandler(
string url,
string httpMethod,
Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> handlerAction
) {
public TestRequestHandler(string url, string httpMethod, HandlerAction handlerAction) {
Url = url;
HttpMethod = httpMethod;
HandlerAction = handlerAction;

_comparisonRegex = CreateComparisonRegex(url);
}

public TestRequestHandler(string url, Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> handlerAction)
: this(url, null, handlerAction) { }
public TestRequestHandler(string url, HandlerAction handlerAction) : this(url, null, handlerAction) { }

string Url { get; }
string HttpMethod { get; }
internal Action<HttpListenerRequest, HttpListenerResponse, Dictionary<string, string>> HandlerAction { get; }
string Url { get; }
string HttpMethod { get; }
internal HandlerAction HandlerAction { get; }

Regex CreateComparisonRegex(string url) {
var regexString = Regex.Escape(url).Replace(@"\{", "{");
@@ -57,8 +51,7 @@ public bool TryMatchUrl(string rawUrl, string httpMethod, out Dictionary<string,

parameters = new Dictionary<string, string>();

for (var i = 0; i < _urlParameterNames.Count; i++)
parameters[_urlParameterNames[i]] = match.Groups[i + 1].Value;
for (var i = 0; i < _urlParameterNames.Count; i++) parameters[_urlParameterNames[i]] = match.Groups[i + 1].Value;
return true;
}
}
}
56 changes: 28 additions & 28 deletions test/RestSharp.Tests/RestSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="SampleData\4sq.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\bearertoken.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\datetimes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\GenericWithList.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\iso8601datetimes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonarray.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsondictionary.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsondictionary_KeysType.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsondictionary_null.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonenums.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonenumtypes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\jsonlists.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\newdatetimes.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\objectproperty.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\person.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\sojson.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\timespans.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="SampleData\underscore_prefix.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Moq"/>
<PackageReference Include="RichardSzalay.MockHttp"/>
<PackageReference Include="System.Net.Http.Json"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\RestSharp\RestSharp.csproj"/>
</ItemGroup>
<ItemGroup>
<None Update="SampleData\4sq.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\bearertoken.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\datetimes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\GenericWithList.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\iso8601datetimes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonarray.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsondictionary.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsondictionary_KeysType.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsondictionary_null.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonenums.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonenumtypes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\jsonlists.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\newdatetimes.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\objectproperty.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\person.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\sojson.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\timespans.json" CopyToOutputDirectory="PreserveNewest"/>
<None Update="SampleData\underscore_prefix.json" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
</Project>