Skip to content

Commit

Permalink
#1 | ADDED: .NET 5.0 as one of Targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanluu committed Nov 23, 2020
1 parent 107b992 commit 10b7759
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
10 changes: 5 additions & 5 deletions TitanShark.Thresher.Core.Tests/InterceptorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public async Task Single_Interceptor_Sequential_Runner()
[Fact]
public Task Multiple_Interceptors_Sequential_Runner_DefaultJsonRecordSerializer()
{
return RunMultipleInterceptors(interceptors => new SequentialInterceptorsRunner(interceptors));
return RunMultipleInterceptors(interceptors => new SequentialInterceptorsRunner(interceptors), new SystemJsonRecordSerializer());
}

[Fact]
public Task Multiple_Interceptors_Parallel_Runner_DefaultJsonRecordSerializer()
{
return RunMultipleInterceptors(interceptors => new ParallelInterceptorsRunner(interceptors));
return RunMultipleInterceptors(interceptors => new ParallelInterceptorsRunner(interceptors), new SystemJsonRecordSerializer());
}

[Fact]
Expand All @@ -68,13 +68,13 @@ public Task Multiple_Interceptors_Parallel_Runner_NewtonsoftJsonRecordSerializer
return RunMultipleInterceptors(interceptors => new ParallelInterceptorsRunner(interceptors), new NewtonsoftJsonRecordSerializer());
}

private async Task RunMultipleInterceptors(Func<IInterceptor[], InterceptorsRunner> runnerCreator, IRecordSerializer<string> serializer = null)
private static async Task RunMultipleInterceptors(Func<IInterceptor[], InterceptorsRunner> runnerCreator, IRecordSerializer<string> serializer)
{
// prepares
var persistenceOne = new InMemoryRecordsPersistence(/*new NewtonsoftJsonRecordSerializer()*/);
var persistenceOne = new InMemoryRecordsPersistence(serializer);
var recorderOne = new Recorder(persistenceOne);

var persistenceTwo = new InMemoryRecordsPersistence(/*new NewtonsoftJsonRecordSerializer()*/);
var persistenceTwo = new InMemoryRecordsPersistence(serializer);
var recorderTwo = new Recorder(persistenceTwo);

var handler = new InterceptableHttpClientHandler(interceptorsRunner: runnerCreator(new[] { recorderOne, recorderTwo }));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion TitanShark.Thresher.Core/TitanShark.Thresher.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462;net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 1 addition & 6 deletions TitanShark.Thresher.Core/_Fundamentals/Transmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ public class Transmitter

public Transmitter(Func<CallId, HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> sendFunction)
{
if (sendFunction == null)
{
throw new ArgumentNullException(nameof(sendFunction));
}

SendFunction = sendFunction;
SendFunction = sendFunction ?? throw new ArgumentNullException(nameof(sendFunction));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ public static async Task<RecordableRequest> ToRecordable(this HttpRequestMessage
{
Headers = request.Headers,
Method = request.Method,
#if NET5_0
Options = request.Options,
VersionPolicy = request.VersionPolicy,
#else
Properties = request.Properties,
#endif
RequestUri = request.RequestUri,
Version = request.Version
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public static async Task<RecordableResponse> ToRecordable(this HttpResponseMessa
ReasonPhrase = response.ReasonPhrase,
RequestMessage = response.RequestMessage,
StatusCode = response.StatusCode,
Version = response.Version
Version = response.Version,
#if NET5_0
TrailingHeaders = response.TrailingHeaders
#endif
};

var content = response.Content;
Expand Down
12 changes: 9 additions & 3 deletions TitanShark.Thresher.Core/_Recording/RecordableRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ public class RecordableRequest
public HttpRequestHeaders Headers { get; set; }

public HttpMethod Method { get; set; }

public IDictionary<string, object> Properties { get; set; }


#if NET5_0
public HttpRequestOptions Options { get; set; }

public HttpVersionPolicy VersionPolicy { get; set; }
#else
public IDictionary<string, object> Properties { get; set; }
#endif

public Uri RequestUri { get; set; }

public Version Version { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions TitanShark.Thresher.Core/_Recording/RecordableResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ public class RecordableResponse
public HttpStatusCode StatusCode { get; set; }

public Version Version { get; set; }

#if NET5_0
public HttpHeaders TrailingHeaders { get; set; }
#endif
}
}

0 comments on commit 10b7759

Please sign in to comment.