Skip to content

Commit

Permalink
Escl: Add timeouts to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Apr 1, 2024
1 parent 7c3b555 commit 6456d1f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion NAPS2.Escl.Tests/ClientServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace NAPS2.Escl.Tests;

public class ClientServerTests
{
[Fact]
[Fact(Timeout = 60_000)]
public async Task ClientServer()
{
var job = Substitute.For<IEsclScanJob>();
Expand Down
4 changes: 2 additions & 2 deletions NAPS2.Sdk.Tests/Remoting/FallbackScanServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace NAPS2.Sdk.Tests.Remoting;
public class FallbackScanServerTests(ITestOutputHelper testOutputHelper) : ScanServerTestsBase(testOutputHelper,
EsclSecurityPolicy.None, new X509Certificate2(BinaryResources.testcert))
{
[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanFallbackFromHttpsToHttp()
{
_bridge.MockOutput = CreateScannedImages(ImageResources.dog);
Expand All @@ -30,7 +30,7 @@ public async Task ScanFallbackFromHttpsToHttp()
ImageAsserts.Similar(ImageResources.dog, images[0]);
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanPreventedByTrustedCertificateSecurityPolicy()
{
var scanResult = _client.Scan(new ScanOptions
Expand Down
16 changes: 8 additions & 8 deletions NAPS2.Sdk.Tests/Remoting/ScanServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ namespace NAPS2.Sdk.Tests.Remoting;
public class ScanServerTests(ITestOutputHelper testOutputHelper)
: ScanServerTestsBase(testOutputHelper, EsclSecurityPolicy.ServerDisableHttps)
{
[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task FindDevice()
{
Assert.True(await TryFindClientDevice());
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task Scan()
{
_bridge.MockOutput = CreateScannedImages(ImageResources.dog);
Expand All @@ -29,7 +29,7 @@ public async Task Scan()
ImageAsserts.Similar(ImageResources.dog, images[0]);
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanMultiplePages()
{
_bridge.MockOutput =
Expand All @@ -45,7 +45,7 @@ public async Task ScanMultiplePages()
ImageAsserts.Similar(ImageResources.dog_h_p300, images[2]);
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanWithCorrectOptions()
{
_bridge.MockOutput = CreateScannedImages(ImageResources.dog);
Expand Down Expand Up @@ -118,7 +118,7 @@ public async Task ScanWithCorrectOptions()
ImageAsserts.Similar(ImageResources.dog_bw, images[0]);
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanWithError()
{
_bridge.Error = new DeviceFeederEmptyException();
Expand All @@ -130,7 +130,7 @@ await Assert.ThrowsAsync<DeviceFeederEmptyException>(async () => await _client.S
}).ToListAsync());
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanWithErrorAfterPage()
{
_bridge.MockOutput = CreateScannedImages(ImageResources.dog);
Expand All @@ -149,7 +149,7 @@ public async Task ScanWithErrorAfterPage()
Assert.Equal(SdkResources.DevicePaperJam, exception.Message);
}

[Fact(Skip = "Flaky")]
[Fact(Timeout = TIMEOUT, Skip = "Flaky")]
public async Task ScanProgress()
{
_bridge.MockOutput = CreateScannedImages(ImageResources.dog, ImageResources.dog);
Expand All @@ -175,7 +175,7 @@ await _client.Scan(new ScanOptions
Arg.Is<PageProgressEventArgs>(args => args.PageNumber == 2 && args.Progress == 0.5));
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanPreventedByHttpsSecurityPolicy()
{
var scanResult = _client.Scan(new ScanOptions
Expand Down
2 changes: 2 additions & 0 deletions NAPS2.Sdk.Tests/Remoting/ScanServerTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace NAPS2.Sdk.Tests.Remoting;

public class ScanServerTestsBase : ContextualTests
{
protected const int TIMEOUT = 60_000;

protected readonly ScanServer _server;
private protected readonly MockScanBridge _bridge;
protected readonly ScanController _client;
Expand Down
6 changes: 3 additions & 3 deletions NAPS2.Sdk.Tests/Remoting/SelfSignedCertScanServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ namespace NAPS2.Sdk.Tests.Remoting;
public class SelfSignedCertScanServerTests(ITestOutputHelper testOutputHelper)
: ScanServerTestsBase(testOutputHelper, EsclSecurityPolicy.RequireHttps)
{
[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task FindDevice()
{
Assert.True(await TryFindClientDevice());
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task Scan()
{
_bridge.MockOutput = CreateScannedImages(ImageResources.dog);
Expand All @@ -33,7 +33,7 @@ public async Task Scan()
ImageAsserts.Similar(ImageResources.dog, images[0]);
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanPreventedByTrustedCertificateSecurityPolicy()
{
var scanResult = _client.Scan(new ScanOptions
Expand Down
6 changes: 3 additions & 3 deletions NAPS2.Sdk.Tests/Remoting/TlsScanServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace NAPS2.Sdk.Tests.Remoting;
public class TlsScanServerTests(ITestOutputHelper testOutputHelper) : ScanServerTestsBase(testOutputHelper,
EsclSecurityPolicy.RequireHttps, new X509Certificate2(BinaryResources.testcert))
{
[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task FindDevice()
{
Assert.True(await TryFindClientDevice());
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task Scan()
{
_bridge.MockOutput = CreateScannedImages(ImageResources.dog);
Expand All @@ -34,7 +34,7 @@ public async Task Scan()
ImageAsserts.Similar(ImageResources.dog, images[0]);
}

[Fact]
[Fact(Timeout = TIMEOUT)]
public async Task ScanPreventedByTrustedCertificateSecurityPolicy()
{
var scanResult = _client.Scan(new ScanOptions
Expand Down

0 comments on commit 6456d1f

Please sign in to comment.