Skip to content

Commit

Permalink
Migrate to .net 8
Browse files Browse the repository at this point in the history
  • Loading branch information
chronoxor committed Nov 19, 2023
1 parent 0fe6886 commit 277e4cf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
16 changes: 8 additions & 8 deletions tests/HttpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ protected override void OnError(SocketError error)
public class HttpTests
{
[Fact(DisplayName = "HTTP server test")]
public async void HttpServerTest()
public void HttpServerTest()
{
string address = "127.0.0.1";
int port = 8080;
Expand All @@ -167,21 +167,21 @@ public async void HttpServerTest()
var client = new HttpClientEx(address, port);

// Test CRUD operations
var response = await client.SendGetRequest("/test");
var response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 404);
response = await client.SendPostRequest("/test", "old_value");
response = client.SendPostRequest("/test", "old_value").Result;
Assert.True(response.Status == 200);
response = await client.SendGetRequest("/test");
response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 200);
Assert.True(response.Body == "old_value");
response = await client.SendPutRequest("/test", "new_value");
response = client.SendPutRequest("/test", "new_value").Result;
Assert.True(response.Status == 200);
response = await client.SendGetRequest("/test");
response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 200);
Assert.True(response.Body == "new_value");
response = await client.SendDeleteRequest("/test");
response = client.SendDeleteRequest("/test").Result;
Assert.True(response.Status == 200);
response = await client.SendGetRequest("/test");
response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 404);

// Stop the HTTP server
Expand Down
16 changes: 8 additions & 8 deletions tests/HttpsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected override void OnError(SocketError error)
public class HttpsTests
{
[Fact(DisplayName = "HTTPS server test")]
public async void HttpsServerTest()
public void HttpsServerTest()
{
string address = "127.0.0.1";
int port = 8443;
Expand All @@ -128,21 +128,21 @@ public async void HttpsServerTest()
var client = new HttpsClientEx(client_context, address, port);

// Test CRUD operations
var response = await client.SendGetRequest("/test");
var response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 404);
response = await client.SendPostRequest("/test", "old_value");
response = client.SendPostRequest("/test", "old_value").Result;
Assert.True(response.Status == 200);
response = await client.SendGetRequest("/test");
response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 200);
Assert.True(response.Body == "old_value");
response = await client.SendPutRequest("/test", "new_value");
response = client.SendPutRequest("/test", "new_value").Result;
Assert.True(response.Status == 200);
response = await client.SendGetRequest("/test");
response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 200);
Assert.True(response.Body == "new_value");
response = await client.SendDeleteRequest("/test");
response = client.SendDeleteRequest("/test").Result;
Assert.True(response.Status == 200);
response = await client.SendGetRequest("/test");
response = client.SendGetRequest("/test").Result;
Assert.True(response.Status == 404);

// Stop the HTTPS server
Expand Down
4 changes: 2 additions & 2 deletions tests/ProtoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public ProtoServer(IPAddress address, int port) : base(address, port)
public class ProtoTests
{
[Fact(DisplayName = "Protocol server test")]
public async void ProtoServerTest()
public void ProtoServerTest()
{
string address = "127.0.0.1";
int port = 4444;
Expand All @@ -282,7 +282,7 @@ public async void ProtoServerTest()
// Send a request to the protocol server
SimpleRequest request = SimpleRequest.Default;
request.Message = "test";
var response = await client.Request(request);
var response = client.Request(request).Result;
Assert.Equal(request.id, response.id);
Assert.Equal(0u, response.Hash);
Assert.Equal(4u, response.Length);
Expand Down
1 change: 1 addition & 0 deletions tests/tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<NoWarn>xUnit1031</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 277e4cf

Please sign in to comment.