Skip to content
Closed
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
14 changes: 7 additions & 7 deletions tests/Sisk.Core/Tests/LargePayloadTests.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Net.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sisk.Cadente;
using Sisk.Cadente.CoreEngine;
using Sisk.Core.Http;
using Sisk.Core.Http.Hosting;
using Sisk.Core.Routing;

namespace tests;
namespace tests.Tests;

[TestClass]
[DoNotParallelize]
public class LargePayloadTests
{
private HttpServerHostContext? _server;
private int _port;

private static int GetRandomPort()
{
using var listener = new System.Net.Sockets.TcpListener(System.Net.IPAddress.Loopback, 0);
listener.Start();
return ((System.Net.IPEndPoint)listener.LocalEndpoint).Port;
return ListeningPort.GetRandomPort().Port;
}

private async Task<string> CalculateHashAsync(Stream stream)
{
byte[] hashBytes = await SHA1.HashDataAsync(stream);
byte[] hashBytes = await SHA256.HashDataAsync(stream);
return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
}

Expand Down Expand Up @@ -92,18 +89,21 @@ private async Task RunPayloadTest(long size)
}

[TestMethod]
[Timeout(300000)] // 5 minutes
public async Task TestPayload_10MB()
{
await RunPayloadTest(10 * 1024 * 1024);
}

[TestMethod]
[Timeout(300000)] // 5 minutes
public async Task TestPayload_100MB()
{
await RunPayloadTest(100 * 1024 * 1024);
}

[TestMethod]
[Timeout(600000)] // 10 minutes
public async Task TestPayload_500MB()
{
await RunPayloadTest(500 * 1024 * 1024);
Expand Down
4 changes: 2 additions & 2 deletions tests/Sisk.Core/Tests/RandomStream.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.IO;

namespace tests;
namespace tests.Tests;

public class RandomStream : Stream
internal sealed class RandomStream : Stream
{
private readonly long _length;
private long _position;
Expand Down
1 change: 0 additions & 1 deletion tests/Sisk.Core/tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

<ItemGroup>
<ProjectReference Include="..\..\cadente\Sisk.Cadente.CoreEngine\Sisk.Cadente.CoreEngine.csproj" />
<ProjectReference Include="..\..\cadente\Sisk.Cadente\Sisk.Cadente.csproj" />
<ProjectReference Include="..\..\src\Sisk.Core.csproj" />
</ItemGroup>

Expand Down