Skip to content

Commit

Permalink
Use xunit async init
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Apr 1, 2024
1 parent 1991b7f commit d1be1c7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions NAPS2.Sdk.Tests/Remoting/ScanServerTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
using NAPS2.Scan.Internal;
using NAPS2.Sdk.Tests.Mocks;
using NSubstitute;
using Xunit;
using Xunit.Abstractions;

namespace NAPS2.Sdk.Tests.Remoting;

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

Expand Down Expand Up @@ -40,19 +41,16 @@ public ScanServerTestsBase(ITestOutputHelper testOutputHelper,
ScanningContext.Logger.LogDebug("Display name: {Name}", displayName);
var serverDevice = new ScanDevice(ScanOptionsValidator.SystemDefaultDriver, "testID", "testName");
_server.RegisterDevice(serverDevice, displayName);
_server.Start().Wait();

// Set up a client ScanController for scanning through EsclScanDriver -> network -> ScanServer
_client = new ScanController(ScanningContext);
var uuid = new ScanServerDevice { Device = serverDevice, Name = displayName }.GetUuid(_server.InstanceId);
_clientDevice = new ScanDevice(Driver.Escl, uuid, displayName);
}

public override void Dispose()
{
_server.Stop().Wait();
base.Dispose();
}
public Task InitializeAsync() => _server.Start();

public Task DisposeAsync() => _server.Stop();

protected async Task<bool> TryFindClientDevice()
{
Expand Down

0 comments on commit d1be1c7

Please sign in to comment.