1c546c111a
- Fix CriteriaSheetGenerator.FormatTimestamp to handle all DateTimeKind values - Update TestWebApplicationFactory to use IAuthenticationService - Add logger parameter to ExcelParserServiceTests - Add SecureStoreManager to solution under /utils/ folder
134 lines
3.8 KiB
C#
134 lines
3.8 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Headless.XUnit;
|
|
using Avalonia.VisualTree;
|
|
using NSubstitute;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using JdeScoping.SecureStoreManager.Services;
|
|
using JdeScoping.SecureStoreManager.ViewModels;
|
|
using JdeScoping.SecureStoreManager.Views;
|
|
|
|
namespace JdeScoping.SecureStoreManager.Tests.Views;
|
|
|
|
public class MainWindowTests
|
|
{
|
|
[AvaloniaFact]
|
|
public void MainWindow_ShowsWithCorrectDefaultTitle()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
window.Title.ShouldBe("SecureStore Manager");
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void MainWindow_HasExpectedWidth()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
window.Width.ShouldBe(800);
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void MainWindow_HasExpectedHeight()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
window.Height.ShouldBe(500);
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void MainWindow_DataContextIsMainWindowViewModel()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
window.DataContext.ShouldBeOfType<MainWindowViewModel>();
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsSecretsDataGrid()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var dataGrid = window.FindDescendantOfType<DataGrid>();
|
|
dataGrid.ShouldNotBeNull();
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void MainWindow_ContainsMenuBar()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
// Assert
|
|
var menu = window.FindDescendantOfType<Menu>();
|
|
menu.ShouldNotBeNull();
|
|
}
|
|
|
|
[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() == "New").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Open").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Save").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Add").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Edit").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Delete").ShouldBeTrue();
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void MainWindow_NewButtonCommand_IsBoundToViewModel()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
var viewModel = window.DataContext as MainWindowViewModel;
|
|
var buttons = window.GetVisualDescendants().OfType<Button>().ToList();
|
|
var newButton = buttons.FirstOrDefault(b => b.Content?.ToString() == "New");
|
|
|
|
// Assert
|
|
newButton.ShouldNotBeNull();
|
|
newButton.Command.ShouldBe(viewModel?.NewStoreCommand);
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void MainWindow_StatusBar_DisplaysStatusMessage()
|
|
{
|
|
// Arrange & Act
|
|
var window = new MainWindow();
|
|
window.Show();
|
|
|
|
var viewModel = window.DataContext as MainWindowViewModel;
|
|
|
|
// Assert - Find status bar text blocks
|
|
var textBlocks = window.GetVisualDescendants().OfType<TextBlock>().ToList();
|
|
// Status message should be "Ready" by default
|
|
textBlocks.Any(tb => tb.Text == viewModel?.StatusMessage).ShouldBeTrue();
|
|
}
|
|
}
|