mirror of
https://github.com/cyanfish/naps2.git
synced 2024-08-16 18:50:45 +03:00
Add more AutoSave tests
This commit is contained in:
parent
3505ef5657
commit
a53bb0201e
@ -62,6 +62,90 @@ namespace NAPS2.Sdk.Tests.Scan
|
||||
errorOutput.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TwoImagesOnePdf()
|
||||
{
|
||||
var errorOutput = new Mock<ErrorOutput>();
|
||||
var driver = Driver(errorOutput.Object, 2);
|
||||
|
||||
var scanProfile = Profile(new AutoSaveSettings
|
||||
{
|
||||
FilePath = Path.Combine(FolderPath, "test$(n).pdf"),
|
||||
Separator = SaveSeparator.FilePerScan
|
||||
});
|
||||
var scanParams = new ScanParams();
|
||||
var scannedImages = await driver.Scan(scanProfile, scanParams).ToList();
|
||||
var files = Folder.GetFiles();
|
||||
|
||||
Assert.Equal(2, scannedImages.Count);
|
||||
Assert.Single(files);
|
||||
PdfAsserts.AssertPageCount(2, files[0].FullName);
|
||||
errorOutput.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TwoImagesTwoPdfs()
|
||||
{
|
||||
var errorOutput = new Mock<ErrorOutput>();
|
||||
var driver = Driver(errorOutput.Object, 2);
|
||||
|
||||
var scanProfile = Profile(new AutoSaveSettings
|
||||
{
|
||||
FilePath = Path.Combine(FolderPath, "test$(n).pdf"),
|
||||
Separator = SaveSeparator.FilePerPage
|
||||
});
|
||||
var scanParams = new ScanParams();
|
||||
var scannedImages = await driver.Scan(scanProfile, scanParams).ToList();
|
||||
var files = Folder.GetFiles();
|
||||
|
||||
Assert.Equal(2, scannedImages.Count);
|
||||
Assert.Equal(2, files.Length);
|
||||
PdfAsserts.AssertPageCount(1, files[0].FullName);
|
||||
PdfAsserts.AssertPageCount(1, files[1].FullName);
|
||||
errorOutput.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TwoImagesTwoJpegs()
|
||||
{
|
||||
var errorOutput = new Mock<ErrorOutput>();
|
||||
var driver = Driver(errorOutput.Object, 2);
|
||||
|
||||
var scanProfile = Profile(new AutoSaveSettings
|
||||
{
|
||||
FilePath = Path.Combine(FolderPath, "test$(n).jpg")
|
||||
});
|
||||
var scanParams = new ScanParams();
|
||||
var scannedImages = await driver.Scan(scanProfile, scanParams).ToList();
|
||||
var files = Folder.GetFiles();
|
||||
|
||||
Assert.Equal(2, scannedImages.Count);
|
||||
Assert.Equal(2, files.Length);
|
||||
errorOutput.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ClearAfterSaving()
|
||||
{
|
||||
var errorOutput = new Mock<ErrorOutput>();
|
||||
var driver = Driver(errorOutput.Object, 2);
|
||||
|
||||
var scanProfile = Profile(new AutoSaveSettings
|
||||
{
|
||||
FilePath = Path.Combine(FolderPath, "test$(n).jpg"),
|
||||
ClearImagesAfterSaving = true
|
||||
});
|
||||
var scanParams = new ScanParams();
|
||||
var scannedImages = await driver.Scan(scanProfile, scanParams).ToList();
|
||||
var files = Folder.GetFiles();
|
||||
|
||||
Assert.Empty(scannedImages);
|
||||
Assert.Equal(2, files.Length);
|
||||
errorOutput.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
// TODO: ClearAfterSaving with error, PromptForFilePath, SaveSeparator
|
||||
|
||||
private ScanDevice Device => new ScanDevice("test_id", "test_name");
|
||||
|
||||
private MockScanDriver Driver(ErrorOutput errorOutput, int images) => new MockScanDriver(errorOutput, CreateAutoSaver(errorOutput))
|
||||
|
@ -141,11 +141,6 @@ namespace NAPS2.Scan
|
||||
[Serializable]
|
||||
public class AutoSaveSettings
|
||||
{
|
||||
public AutoSaveSettings()
|
||||
{
|
||||
Separator = SaveSeparator.FilePerPage;
|
||||
}
|
||||
|
||||
internal AutoSaveSettings Clone() => (AutoSaveSettings) MemberwiseClone();
|
||||
|
||||
public string FilePath { get; set; }
|
||||
@ -154,7 +149,7 @@ namespace NAPS2.Scan
|
||||
|
||||
public bool ClearImagesAfterSaving { get; set; }
|
||||
|
||||
public SaveSeparator Separator { get; set; }
|
||||
public SaveSeparator Separator { get; set; } = SaveSeparator.FilePerPage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -6,4 +6,6 @@
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue"><data><IncludeFilters /><ExcludeFilters /></data></s:String>
|
||||
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue"><data /></s:String>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Lineart/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Jpegs/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Lineart/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pdfs/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
Loading…
Reference in New Issue
Block a user