Compare commits

...

3 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
fddb0167ab Add XML documentation for Name property validation behavior
Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
2026-02-05 15:21:21 +00:00
copilot-swe-agent[bot]
bf7b762576 Add validation to prevent empty/null names in ImageResizer settings
Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
2026-02-05 15:19:36 +00:00
copilot-swe-agent[bot]
3857cf809d Initial plan 2026-02-05 15:16:59 +00:00
2 changed files with 51 additions and 1 deletions

View File

@@ -65,11 +65,22 @@ public partial class ImageSize : INotifyPropertyChanged, IHasId
get => !(Unit == ResizeUnit.Percent && Fit != ResizeFit.Stretch);
}
/// <summary>
/// Gets or sets the name of the image size.
/// Invalid values (null, empty, or whitespace) are silently ignored to maintain the existing name.
/// </summary>
[JsonPropertyName("name")]
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
set
{
// Prevent setting empty or null names
if (!string.IsNullOrWhiteSpace(value))
{
SetProperty(ref _name, value);
}
}
}
[JsonPropertyName("fit")]

View File

@@ -313,5 +313,44 @@ namespace ViewModelTests
Assert.AreEqual(50, imageSize.Width);
Assert.AreEqual(50, imageSize.Height);
}
[TestMethod]
public void ImageSizeNameShouldNotBeSetToEmptyOrNull()
{
// arrange
ImageSize imageSize = new ImageSize()
{
Id = 0,
Name = "Original Name",
Fit = ResizeFit.Fit,
Width = 100,
Height = 100,
Unit = ResizeUnit.Pixel,
};
// Act - try to set name to empty string
imageSize.Name = string.Empty;
// Assert - name should remain unchanged
Assert.AreEqual("Original Name", imageSize.Name);
// Act - try to set name to null
imageSize.Name = null;
// Assert - name should remain unchanged
Assert.AreEqual("Original Name", imageSize.Name);
// Act - try to set name to whitespace only
imageSize.Name = " ";
// Assert - name should remain unchanged
Assert.AreEqual("Original Name", imageSize.Name);
// Act - set name to valid value
imageSize.Name = "New Valid Name";
// Assert - name should be updated
Assert.AreEqual("New Valid Name", imageSize.Name);
}
}
}