feat: Update package references and enhance AI extraction service with CSV output functionality
This commit is contained in:
parent
55e8f0face
commit
af74c90ce7
12 changed files with 400 additions and 153 deletions
58
MaddoShared.Tests/PickerPreferenceServiceTests.cs
Normal file
58
MaddoShared.Tests/PickerPreferenceServiceTests.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using ImageCatalog;
|
||||
using ImageCatalog_2.Services;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Shouldly;
|
||||
|
||||
namespace MaddoShared.Tests;
|
||||
|
||||
[TestClass]
|
||||
public class PickerPreferenceServiceTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void RememberValue_PersistsExactFilePath()
|
||||
{
|
||||
using var tempDirectory = new TemporaryDirectory();
|
||||
var preferencesFile = Path.Combine(tempDirectory.Path, "userprefs.xml");
|
||||
var service = new PickerPreferenceService(new ParametriSetup(preferencesFile));
|
||||
var settingsFile = Path.Combine(tempDirectory.Path, "nested", "settings.xml");
|
||||
|
||||
service.RememberValue(PickerPreferenceKeys.LastSettingsFile, settingsFile);
|
||||
|
||||
service.GetRememberedValue(PickerPreferenceKeys.LastSettingsFile).ShouldBe(settingsFile);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ForgetValue_RemovesStoredPreference()
|
||||
{
|
||||
using var tempDirectory = new TemporaryDirectory();
|
||||
var preferencesFile = Path.Combine(tempDirectory.Path, "userprefs.xml");
|
||||
var service = new PickerPreferenceService(new ParametriSetup(preferencesFile));
|
||||
|
||||
service.RememberValue(PickerPreferenceKeys.LastSettingsFile, Path.Combine(tempDirectory.Path, "settings.xml"));
|
||||
|
||||
service.ForgetValue(PickerPreferenceKeys.LastSettingsFile);
|
||||
|
||||
service.GetRememberedValue(PickerPreferenceKeys.LastSettingsFile).ShouldBeNull();
|
||||
}
|
||||
|
||||
private sealed class TemporaryDirectory : IDisposable
|
||||
{
|
||||
public TemporaryDirectory()
|
||||
{
|
||||
Path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName());
|
||||
Directory.CreateDirectory(Path);
|
||||
}
|
||||
|
||||
public string Path { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Directory.Exists(Path))
|
||||
{
|
||||
Directory.Delete(Path, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue