Mac: Fix more minor test issues

This commit is contained in:
Ben Olden-Cooligan 2022-08-13 20:58:41 -04:00
parent 6bb55b1a59
commit 69954ab820
7 changed files with 26 additions and 26 deletions

View File

@ -1,4 +1,3 @@
using NAPS2.Images.Gdi;
using NAPS2.Scan;
using NAPS2.Sdk.Tests;
using Xunit;
@ -23,7 +22,7 @@ public class ServerDiscoveryTests
Assert.Contains(discovered, x => x.Name == "NetworkScanTests.ServerDiscovery");
}
[Fact]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task ServerDiscoveryCustomPort()
{
using var server = CreateServer(new NetworkScanServerOptions
@ -41,7 +40,7 @@ public class ServerDiscoveryTests
Assert.Contains(discovered, x => x.Name == "NetworkScanTests.ServerDiscoveryCustomPort");
}
[Fact]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task ServerDiscoveryMismatchPort()
{
using var server = CreateServer(new NetworkScanServerOptions
@ -59,7 +58,7 @@ public class ServerDiscoveryTests
Assert.DoesNotContain(discovered, x => x.Name == "NetworkScanTests.ServerDiscoveryMismatchPort");
}
[Fact]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task ServerDiscoveryOff()
{
using var server = CreateServer(new NetworkScanServerOptions

View File

@ -332,7 +332,8 @@ public class ImageSerializerTests : ContextualTests
});
using var destImage = ImageSerializer.Deserialize(destContext, serializedImage, new DeserializeImageOptions());
ImageAsserts.Similar(ImageResources.color_image_thumb_256, destImage.PostProcessingData.Thumbnail, ignoreResolution: true);
ImageAsserts.Similar(ImageResources.color_image_thumb_256, destImage.PostProcessingData.Thumbnail,
ImageAsserts.XPLAT_RMSE_THRESHOLD, ignoreResolution: true);
}
[Fact]

View File

@ -8,7 +8,7 @@ namespace NAPS2.Sdk.Tests.ImportExport.Pdf;
public class PdfATests : ContextualTests
{
// Sadly the pdfa verifier library only supports windows/mac
[PlatformFact(exclude: Platform.Mac)]
[PlatformFact(exclude: PlatformFlags.Mac)]
public async Task Validate()
{
var pdfExporter = new PdfExporter(ScanningContext);

View File

@ -5,40 +5,40 @@ namespace NAPS2.Sdk.Tests;
public sealed class PlatformFactAttribute : FactAttribute
{
public PlatformFactAttribute(Platform include = Platform.None, Platform exclude = Platform.None)
public PlatformFactAttribute(PlatformFlags include = PlatformFlags.None, PlatformFlags exclude = PlatformFlags.None)
{
if (include != Platform.None && (GetPlatform() & include) != include)
if (include != PlatformFlags.None && (GetPlatform() & include) != include)
{
Skip = $"Only runs on platform: {include}";
}
if (exclude != Platform.None && (GetPlatform() & exclude) != Platform.None)
if (exclude != PlatformFlags.None && (GetPlatform() & exclude) != PlatformFlags.None)
{
Skip = $"Doesn't runs on platform: {exclude}";
}
}
private Platform GetPlatform()
private PlatformFlags GetPlatform()
{
var p = Platform.None;
var p = PlatformFlags.None;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
p |= Platform.Windows;
p |= PlatformFlags.Windows;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
p |= Platform.Mac;
p |= PlatformFlags.Mac;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
p |= Platform.Linux;
p |= PlatformFlags.Linux;
}
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
{
p |= Platform.X64;
p |= PlatformFlags.X64;
}
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
p |= Platform.Arm64;
p |= PlatformFlags.Arm64;
}
return p;
}

View File

@ -1,7 +1,7 @@
namespace NAPS2.Sdk.Tests;
[Flags]
public enum Platform
public enum PlatformFlags
{
None = 0,
Windows = 1,

View File

@ -5,7 +5,7 @@ namespace NAPS2.Sdk.Tests.Serialization;
public class SecureStorageTests
{
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public void EncryptAndDecrypt()
{
var text = "Hello, world!";
@ -17,7 +17,7 @@ public class SecureStorageTests
Assert.Equal(text, decrypted);
}
[PlatformFact(exclude: Platform.Windows)]
[PlatformFact(exclude: PlatformFlags.Windows)]
public void EncryptAndDecryptNonWindows()
{
var text = "Hello, world!";

View File

@ -44,7 +44,7 @@ public class WorkerChannelTests : ContextualTests
// channel.Client.Init(null);
// }
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public void Init()
{
using var channel = Start();
@ -52,14 +52,14 @@ public class WorkerChannelTests : ContextualTests
Assert.StartsWith(@"C:\Somewhere", ScanningContext.FileStorageManager.NextFilePath());
}
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public void Wia10NativeUi()
{
// TODO: This is not testable yet
// channel.Client.Wia10NativeUI(...);
}
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task GetDeviceList()
{
var remoteScanController = new Mock<IRemoteScanController>();
@ -77,13 +77,13 @@ public class WorkerChannelTests : ContextualTests
remoteScanController.VerifyNoOtherCalls();
}
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task ScanWithMemoryStorage()
{
await ScanInternalTest();
}
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task ScanWithFileStorage()
{
ScanningContext.FileStorageManager = FileStorageManager.CreateFolder(Path.Combine(FolderPath, "recovery"));
@ -114,7 +114,7 @@ public class WorkerChannelTests : ContextualTests
// TODO: Verify that thumbnails are set correctly (with and without revertible transforms)
}
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task ScanException()
{
var remoteScanController = new MockRemoteScanController
@ -137,7 +137,7 @@ public class WorkerChannelTests : ContextualTests
Assert.Contains("Test error", ex.Message);
}
[PlatformFact(include: Platform.Windows)]
[PlatformFact(include: PlatformFlags.Windows)]
public async Task TwainScan()
{
var twainEvents = new Mock<ITwainEvents>();