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
115 lines
3.1 KiB
C#
115 lines
3.1 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 SecretEditDialogTests
|
|
{
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_DefaultConstructor_ShowsAddSecretTitle()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog();
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
dialog.Title.ShouldBe("Add Secret");
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_WithKeyValueParams_ShowsEditSecretTitle()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog("existingKey", "existingValue");
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
dialog.Title.ShouldBe("Edit Secret");
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_DataContextIsSecretEditDialogViewModel()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog();
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
dialog.DataContext.ShouldBeOfType<SecretEditDialogViewModel>();
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_HasKeyAndValueTextBoxes()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog();
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
var textBoxes = dialog.GetVisualDescendants().OfType<TextBox>().ToList();
|
|
textBoxes.Count.ShouldBeGreaterThanOrEqualTo(2);
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_HasSaveAndCancelButtons()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog();
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
var buttons = dialog.GetVisualDescendants().OfType<Button>().ToList();
|
|
buttons.Any(b => b.Content?.ToString() == "Save").ShouldBeTrue();
|
|
buttons.Any(b => b.Content?.ToString() == "Cancel").ShouldBeTrue();
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_ViewModelProperty_ReturnsDataContext()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog();
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
dialog.ViewModel.ShouldBe(dialog.DataContext);
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_ParameterizedConstructor_SetsViewModelWithKey()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog("testKey", "testValue");
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
dialog.ViewModel.Key.ShouldBe("testKey");
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_ParameterizedConstructor_SetsViewModelWithValue()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog("testKey", "testValue");
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
dialog.ViewModel.Value.ShouldBe("testValue");
|
|
}
|
|
|
|
[AvaloniaFact]
|
|
public void SecretEditDialog_CannotResize()
|
|
{
|
|
// Arrange & Act
|
|
var dialog = new SecretEditDialog();
|
|
dialog.Show();
|
|
|
|
// Assert
|
|
dialog.CanResize.ShouldBeFalse();
|
|
}
|
|
}
|