Phase 2-3: UI layout, theme switching, CRUD tools, process execution
- Phase 2: MainWindow 3-section layout (sidebar/content/log bar), Dark/Light theme with ThemeHelper, MainViewModel with ObservableProperty/RelayCommand, tool card filtering by search + category - Phase 3: ToolEditWindow for add/edit tools, ProcessExecutionService (Process.Start + error handling), double-click + right-click context menu (run/edit), path browse dialog - Bugfix: ContextMenu commands now use PlacementTarget.Tag binding (ContextMenu in separate visual tree) - Bugfix: StaticResource converters moved to XAML before DataTemplate to fix XamlParseException on tool card render - Bugfix: Pure filenames (no path separators) treated as PATH commands, not marked invalid - Bugfix: RefreshData preserves SelectedCategory; Load() catches all exceptions; Save() wrapped in try-catch; auto-scroll log to newest entry - Tests: xUnit project with 55 tests covering models, services, converters, and view models
This commit is contained in:
67
PersonalToolBox.Tests/Views/ConverterTests.cs
Normal file
67
PersonalToolBox.Tests/Views/ConverterTests.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Globalization;
|
||||
using PersonalToolBox.Views;
|
||||
|
||||
namespace PersonalToolBox.Tests.Views;
|
||||
|
||||
public class ConverterTests
|
||||
{
|
||||
[Fact]
|
||||
public void BoolToOpacityConverter_True_ReturnsOne()
|
||||
{
|
||||
var converter = new BoolToOpacityConverter();
|
||||
|
||||
var result = converter.Convert(true, typeof(double), null, CultureInfo.InvariantCulture);
|
||||
|
||||
Assert.Equal(1.0, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BoolToOpacityConverter_False_ReturnsZeroPointFour()
|
||||
{
|
||||
var converter = new BoolToOpacityConverter();
|
||||
|
||||
var result = converter.Convert(false, typeof(double), null, CultureInfo.InvariantCulture);
|
||||
|
||||
Assert.Equal(0.4, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BoolToOpacityConverter_NonBool_ReturnsZeroPointFour()
|
||||
{
|
||||
var converter = new BoolToOpacityConverter();
|
||||
|
||||
var result = converter.Convert("not a bool", typeof(double), null, CultureInfo.InvariantCulture);
|
||||
|
||||
Assert.Equal(0.4, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FirstCharConverter_NormalString_ReturnsFirstChar()
|
||||
{
|
||||
var converter = new FirstCharConverter();
|
||||
|
||||
var result = converter.Convert("Postman", typeof(string), null, CultureInfo.InvariantCulture);
|
||||
|
||||
Assert.Equal("P", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FirstCharConverter_EmptyString_ReturnsQuestionMark()
|
||||
{
|
||||
var converter = new FirstCharConverter();
|
||||
|
||||
var result = converter.Convert("", typeof(string), null, CultureInfo.InvariantCulture);
|
||||
|
||||
Assert.Equal("?", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FirstCharConverter_Null_ReturnsQuestionMark()
|
||||
{
|
||||
var converter = new FirstCharConverter();
|
||||
|
||||
var result = converter.Convert(null!, typeof(string), null, CultureInfo.InvariantCulture);
|
||||
|
||||
Assert.Equal("?", result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user