Compare commits

...

2 Commits

Author SHA1 Message Date
Leilei Zhang
cbadd63774 fix tests 2026-01-13 09:29:18 +08:00
Leilei Zhang
d72473cb4f fix imageresizer 2026-01-12 21:57:04 +08:00
3 changed files with 7 additions and 22 deletions

View File

@@ -31,7 +31,7 @@ internal static class Program
Console.InputEncoding = Encoding.Unicode; Console.InputEncoding = Encoding.Unicode;
// Initialize logger to file (same as other modules) // Initialize logger to file (same as other modules)
CliLogger.Initialize("\\ImageResizer\\Logs"); CliLogger.Initialize("\\Image Resizer\\CLI");
CliLogger.Info($"ImageResizerCLI started with {args.Length} argument(s)"); CliLogger.Info($"ImageResizerCLI started with {args.Length} argument(s)");
try try

View File

@@ -126,13 +126,10 @@ namespace ImageResizer.Properties
h => ncc.CollectionChanged -= h, h => ncc.CollectionChanged -= h,
() => settings.CustomSize = new CustomSize()); () => settings.CustomSize = new CustomSize());
Assert.AreEqual(NotifyCollectionChangedAction.Replace, result.Arguments.Action); // Reset is used instead of Replace to avoid ArgumentOutOfRangeException
Assert.AreEqual(1, result.Arguments.NewItems.Count); // when notifying changes for virtual items (CustomSize/AiSize) that exist
Assert.AreEqual(settings.CustomSize, result.Arguments.NewItems[0]); // outside the bounds of the underlying _sizes collection.
Assert.AreEqual(0, result.Arguments.NewStartingIndex); Assert.AreEqual(NotifyCollectionChangedAction.Reset, result.Arguments.Action);
Assert.AreEqual(1, result.Arguments.OldItems.Count);
Assert.AreEqual(originalCustomSize, result.Arguments.OldItems[0]);
Assert.AreEqual(0, result.Arguments.OldStartingIndex);
} }
[TestMethod] [TestMethod]

View File

@@ -216,27 +216,15 @@ namespace ImageResizer.Properties
{ {
if (e.PropertyName == nameof(Models.CustomSize)) if (e.PropertyName == nameof(Models.CustomSize))
{ {
var oldCustomSize = _customSize;
_customSize = settings.CustomSize; _customSize = settings.CustomSize;
OnCollectionChanged( OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
new NotifyCollectionChangedEventArgs(
NotifyCollectionChangedAction.Replace,
_customSize,
oldCustomSize,
_sizes.Count));
} }
else if (e.PropertyName == nameof(Models.AiSize)) else if (e.PropertyName == nameof(Models.AiSize))
{ {
var oldAiSize = _aiSize;
_aiSize = settings.AiSize; _aiSize = settings.AiSize;
OnCollectionChanged( OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
new NotifyCollectionChangedEventArgs(
NotifyCollectionChangedAction.Replace,
_aiSize,
oldAiSize,
_sizes.Count + 1));
} }
else if (e.PropertyName == nameof(Sizes)) else if (e.PropertyName == nameof(Sizes))
{ {