Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<PropertyGroup Label="Package versions for .NET 10" Condition="'$(TargetFramework)' == 'net10.0'">
<MicrosoftTestHostVer>10.0.0-rc.2.25502.107</MicrosoftTestHostVer>
<SystemTextJsonVer>10.0.0-rc.2.25502.107</SystemTextJsonVer>
<MicrosoftTestHostVer>10.0.0</MicrosoftTestHostVer>
<SystemTextJsonVer>10.0.0</SystemTextJsonVer>
</PropertyGroup>
<PropertyGroup Label="Package versions for .NET 9" Condition="'$(TargetFramework)' == 'net9.0'">
<MicrosoftTestHostVer>9.0.10</MicrosoftTestHostVer>
Expand Down Expand Up @@ -46,7 +46,7 @@
<PackageVersion Include="Xunit.Extensions.Logging" Version="1.1.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="All" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="WireMock.Net" Version="1.15.0" />
<PackageVersion Include="WireMock.Net" Version="1.16.0" />
<PackageVersion Include="WireMock.Net.FluentAssertions" Version="1.5.51" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion test/RestSharp.Tests.Integrated/CompressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task Can_Handle_Deflate_Compressed_Content() {
var body = await GetBody(s => new DeflateStream(s, CompressionMode.Compress, true), value);
ConfigureServer(server, body, "deflate");

using var client = new RestClient(server.Url!);
using var client = new RestClient(server.Url!, options => options.AutomaticDecompression = DecompressionMethods.Deflate);
var request = new RestRequest("");
var response = await client.ExecuteAsync(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,7 @@ class StupidClass {

readonly WireMockServer _server = WireMockServer.Start();

/// <summary>
/// Success of this test is based largely on the behavior of your current DNS.
/// For example, if you're using OpenDNS this will test will fail; ResponseStatus will be Completed.
/// </summary>
[Fact]
public async Task Handles_Non_Existent_Domain() {
using var client = new RestClient("http://nonexistantdomainimguessing.org");

var request = new RestRequest("foo");
var response = await client.ExecuteAsync(request);

response.ResponseStatus.Should().Be(ResponseStatus.Error);
}

#if NET
[Fact]
public async Task Handles_HttpClient_Timeout_Error() {
using var client = new RestClient(new HttpClient { Timeout = TimeSpan.FromMilliseconds(500) });
Expand All @@ -38,8 +25,9 @@ public async Task Handles_HttpClient_Timeout_Error() {
var response = await client.ExecuteAsync(request);

response.ErrorException.Should().BeOfType<TaskCanceledException>();
response.ResponseStatus.Should().Be(ResponseStatus.TimedOut);
response.ResponseStatus.Should().Be(ResponseStatus.TimedOut, response.ErrorMessage);
}
#endif

[Fact]
public async Task Handles_Server_Timeout_Error() {
Expand All @@ -65,7 +53,7 @@ public async Task Handles_Server_Timeout_Error_With_Deserializer() {
}

[Fact]
public async Task Task_Handles_Non_Existent_Domain() {
public async Task Handles_Non_Existent_Domain() {
using var client = new RestClient("http://this.cannot.exist:8001");

var request = new RestRequest("/") {
Expand All @@ -75,7 +63,6 @@ public async Task Task_Handles_Non_Existent_Domain() {
var response = await client.ExecuteAsync<StupidClass>(request);

response.ErrorException.Should().BeOfType<HttpRequestException>();
response.ErrorException!.Message.Should().Contain("known");
response.ResponseStatus.Should().Be(ResponseStatus.Error);
}
}
2 changes: 2 additions & 0 deletions test/RestSharp.Tests.Integrated/RequestBodyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public sealed class RequestBodyTests : IDisposable {
readonly WireMockServer _server = WireMockServer.Start(s => s.AllowBodyForAllHttpMethods = true);

async Task AssertBody(Method method, bool disableCharset = false) {
#if NET
var options = new RestClientOptions(_server.Url!) { DisableCharset = disableCharset };
using var client = new RestClient(options);
var request = new RestRequest(RequestBodyCapturer.Resource, method);
Expand All @@ -25,6 +26,7 @@ async Task AssertBody(Method method, bool disableCharset = false) {

var expected = disableCharset ? ExpectedTextContentTypeNoCharset : ExpectedTextContentType;
AssertHasRequestBody(capturer, expected, bodyData);
#endif
}

[Fact]
Expand Down
4 changes: 3 additions & 1 deletion test/RestSharp.Tests.Integrated/RequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public async Task Can_Perform_GET_Async() {
response.Content.Should().Be(val);
}

#if NET
[Fact]
public async Task Can_Timeout_GET_Async() {
var request = new RestRequest("timeout").AddBody("Body_Content");
Expand All @@ -59,8 +60,9 @@ public async Task Can_Timeout_GET_Async() {

var response = await _client.ExecuteAsync(request);

Assert.Equal(ResponseStatus.TimedOut, response.ResponseStatus);
response.ResponseStatus.Should().Be(ResponseStatus.TimedOut, response.ErrorMessage);
}
#endif

[Fact]
public async Task Can_Perform_Delete_With_Response_Type() {
Expand Down
Loading