Files
jdescopingtool/NEW/tests/JdeScoping.SecureStoreManager.Tests/Views/NewStoreDialogTests.cs
T
Joseph Doherty 1b7bb26def refactor(securestore): remove password-based authentication in favor of key-file only
Simplify SecureStore by removing MasterKeyEnvVar and password-based methods, leaving only key-file authentication for better security practices.
2026-01-23 00:17:19 -05:00

94 lines
2.5 KiB
C#

using Avalonia.Controls;
using Avalonia.Headless.XUnit;
using Avalonia.VisualTree;
using Shouldly;
using Xunit;
using JdeScoping.SecureStoreManager.ViewModels;
using JdeScoping.SecureStoreManager.Views;
namespace JdeScoping.SecureStoreManager.Tests.Views;
public class NewStoreDialogTests
{
[AvaloniaFact]
public void NewStoreDialog_ShowsWithCorrectTitle()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
dialog.Title.ShouldBe("Create New Store");
}
[AvaloniaFact]
public void NewStoreDialog_DataContextIsNewStoreDialogViewModel()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
dialog.DataContext.ShouldBeOfType<NewStoreDialogViewModel>();
}
[AvaloniaFact]
public void NewStoreDialog_HasStorePathTextBox()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
var textBoxes = dialog.GetVisualDescendants().OfType<TextBox>().ToList();
textBoxes.Count.ShouldBeGreaterThan(0);
}
[AvaloniaFact]
public void NewStoreDialog_HasKeyFilePathTextBox()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert - Should have at least 2 text boxes: store path and key file path
var textBoxes = dialog.GetVisualDescendants().OfType<TextBox>().ToList();
textBoxes.Count.ShouldBeGreaterThanOrEqualTo(2);
}
[AvaloniaFact]
public void NewStoreDialog_HasCreateAndCancelButtons()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
var buttons = dialog.GetVisualDescendants().OfType<Button>().ToList();
buttons.Any(b => b.Content?.ToString() == "Create").ShouldBeTrue();
buttons.Any(b => b.Content?.ToString() == "Cancel").ShouldBeTrue();
}
[AvaloniaFact]
public void NewStoreDialog_ViewModelProperty_ReturnsDataContext()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
dialog.ViewModel.ShouldBe(dialog.DataContext);
}
[AvaloniaFact]
public void NewStoreDialog_CannotResize()
{
// Arrange & Act
var dialog = new NewStoreDialog();
dialog.Show();
// Assert
dialog.CanResize.ShouldBeFalse();
}
}