mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Mac: Fix more minor test issues
This commit is contained in:
parent
6bb55b1a59
commit
69954ab820
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace NAPS2.Sdk.Tests;
|
||||
|
||||
[Flags]
|
||||
public enum Platform
|
||||
public enum PlatformFlags
|
||||
{
|
||||
None = 0,
|
||||
Windows = 1,
|
@ -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!";
|
||||
|
@ -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>();
|
||||
|
Loading…
Reference in New Issue
Block a user