1fc7792cd1
Rename ConfigManager to ConfigManager.Ui to match the Core/CLI/UI project structure, and split the monolithic test project into Core.Tests, Cli.Tests, and Ui.Tests to align with the source project organization.
162 lines
4.9 KiB
C#
162 lines
4.9 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Headless.XUnit;
|
|
using Avalonia.VisualTree;
|
|
using JdeScoping.ConfigManager.Ui.Views;
|
|
|
|
namespace JdeScoping.ConfigManager.Ui.Tests.Views;
|
|
|
|
/// <summary>
|
|
/// UI tests for <see cref="MainWindow"/>.
|
|
/// </summary>
|
|
public class MainWindowTests
|
|
{
|
|
/// <summary>
|
|
/// Verifies that the main window displays with the correct title.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_ShowsWithCorrectTitle()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
window.Title.ShouldBe("JdeScoping ConfigManager");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the main window contains a TreeView for navigation.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsTreeView()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var treeView = window.FindDescendantOfType<TreeView>();
|
|
treeView.ShouldNotBeNull();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the main window contains a menu bar.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsMenuBar()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var menu = window.FindDescendantOfType<Menu>();
|
|
menu.ShouldNotBeNull();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the main window has the expected minimum size constraints.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_HasExpectedMinimumSize()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert - MinWidth=900, MinHeight=600 as defined in AXAML
|
|
window.MinWidth.ShouldBe(900);
|
|
window.MinHeight.ShouldBe(600);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the main window has the expected default size.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_HasExpectedDefaultSize()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert - Width=1200, Height=800 as defined in AXAML
|
|
window.Width.ShouldBe(1200);
|
|
window.Height.ShouldBe(800);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the main window contains toolbar buttons.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsToolbarButtons()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var buttons = window.GetVisualDescendants().OfType<Button>().ToList();
|
|
buttons.Count.ShouldBeGreaterThan(0);
|
|
|
|
// Verify toolbar buttons exist with expected content
|
|
buttons.Any(b => b.Content?.ToString() == "Open").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Save").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Undo").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Redo").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Validate").ShouldBeTrue();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the main window contains a ContentControl for form display.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsFormContentControl()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var contentControl = window.FindDescendantOfType<ContentControl>();
|
|
contentControl.ShouldNotBeNull();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the main window contains a GridSplitter for resizing panels.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsGridSplitter()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var splitter = window.FindDescendantOfType<GridSplitter>();
|
|
splitter.ShouldNotBeNull();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the menu contains expected menu items.
|
|
/// </summary>
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsExpectedMenuItems()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var menuItems = window.GetVisualDescendants().OfType<MenuItem>().ToList();
|
|
menuItems.Count.ShouldBeGreaterThan(0);
|
|
|
|
// Verify top-level menu items exist
|
|
menuItems.Any(m => m.Header?.ToString() == "_File").ShouldBeTrue();
|
|
menuItems.Any(m => m.Header?.ToString() == "_Edit").ShouldBeTrue();
|
|
menuItems.Any(m => m.Header?.ToString() == "_Tools").ShouldBeTrue();
|
|
menuItems.Any(m => m.Header?.ToString() == "_Pipelines").ShouldBeTrue();
|
|
menuItems.Any(m => m.Header?.ToString() == "_Secure Stores").ShouldBeTrue();
|
|
menuItems.Any(m => m.Header?.ToString() == "_Help").ShouldBeTrue();
|
|
}
|
|
}
|