9bf0c29add
Consolidate SecureStoreLockedFormView and SecureStoreUnlockedFormView into a single SecureStoreInfoFormView that displays store status and metadata. Simplifies MainWindowViewModel by removing redundant state management. Also adds design docs for RegexTransformer feature.
150 lines
4.4 KiB
C#
150 lines
4.4 KiB
C#
using JdeScoping.ConfigManager.Models;
|
|
using JdeScoping.ConfigManager.ViewModels.Forms;
|
|
|
|
namespace JdeScoping.ConfigManager.Tests.ViewModels.Forms;
|
|
|
|
public class ExcelExportFormViewModelTests
|
|
{
|
|
[Fact]
|
|
public void Constructor_InitializesFromModel()
|
|
{
|
|
// Arrange
|
|
var model = new ExcelExportSection
|
|
{
|
|
MaxRowsPerSheet = 500000,
|
|
DefaultDateFormat = "MM/dd/yyyy",
|
|
DebugWriteToFile = true,
|
|
DebugOutputDirectory = "/tmp/debug",
|
|
TimezoneId = "America/Los_Angeles"
|
|
};
|
|
|
|
// Act
|
|
var sut = new ExcelExportFormViewModel(model, () => { });
|
|
|
|
// Assert
|
|
sut.MaxRowsPerSheet.ShouldBe(500000);
|
|
sut.DefaultDateFormat.ShouldBe("MM/dd/yyyy");
|
|
sut.DebugWriteToFile.ShouldBeTrue();
|
|
sut.DebugOutputDirectory.ShouldBe("/tmp/debug");
|
|
sut.SelectedTimezone.ShouldBe("America/Los_Angeles");
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_UsesModelTimezone()
|
|
{
|
|
// Arrange - model defaults to "America/Chicago"
|
|
var model = new ExcelExportSection();
|
|
|
|
// Act
|
|
var sut = new ExcelExportFormViewModel(model, () => { });
|
|
|
|
// Assert
|
|
sut.SelectedTimezone.ShouldBe("America/Chicago");
|
|
}
|
|
|
|
[Fact]
|
|
public void AvailableTimezones_ContainsSystemTimezones()
|
|
{
|
|
// Act & Assert
|
|
ExcelExportFormViewModel.AvailableTimezones.ShouldNotBeEmpty();
|
|
// Check for common IANA timezones
|
|
ExcelExportFormViewModel.AvailableTimezones.ShouldContain("America/Chicago");
|
|
ExcelExportFormViewModel.AvailableTimezones.ShouldContain("UTC");
|
|
}
|
|
|
|
[Fact]
|
|
public void PropertyChange_UpdatesModel()
|
|
{
|
|
// Arrange
|
|
var model = new ExcelExportSection { MaxRowsPerSheet = 1000000 };
|
|
var sut = new ExcelExportFormViewModel(model, () => { });
|
|
|
|
// Act
|
|
sut.MaxRowsPerSheet = 750000;
|
|
|
|
// Assert
|
|
model.MaxRowsPerSheet.ShouldBe(750000);
|
|
}
|
|
|
|
[Fact]
|
|
public void SelectedTimezone_UpdatesModelTimezoneId()
|
|
{
|
|
// Arrange - model defaults to "America/Chicago"
|
|
var model = new ExcelExportSection();
|
|
var sut = new ExcelExportFormViewModel(model, () => { });
|
|
|
|
// Act - change to a different timezone
|
|
sut.SelectedTimezone = "America/New_York";
|
|
|
|
// Assert
|
|
model.TimezoneId.ShouldBe("America/New_York");
|
|
}
|
|
|
|
[Fact]
|
|
public void PropertyChange_InvokesOnChanged()
|
|
{
|
|
// Arrange
|
|
var model = new ExcelExportSection(); // Default TimezoneId is "America/Chicago"
|
|
var changedInvoked = false;
|
|
var sut = new ExcelExportFormViewModel(model, () => changedInvoked = true);
|
|
|
|
// Act - change to a different timezone than the default
|
|
sut.SelectedTimezone = "America/Denver";
|
|
|
|
// Assert
|
|
changedInvoked.ShouldBeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void PropertyChange_RaisesPropertyChanged()
|
|
{
|
|
// Arrange
|
|
var model = new ExcelExportSection();
|
|
var sut = new ExcelExportFormViewModel(model, () => { });
|
|
var propertyChangedRaised = false;
|
|
sut.PropertyChanged += (s, e) =>
|
|
{
|
|
if (e.PropertyName == nameof(ExcelExportFormViewModel.DefaultDateFormat))
|
|
propertyChangedRaised = true;
|
|
};
|
|
|
|
// Act
|
|
sut.DefaultDateFormat = "dd-MMM-yyyy";
|
|
|
|
// Assert
|
|
propertyChangedRaised.ShouldBeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void SameValueAssignment_DoesNotInvokeOnChanged()
|
|
{
|
|
// Arrange
|
|
var model = new ExcelExportSection { DebugWriteToFile = true };
|
|
var changedInvoked = false;
|
|
var sut = new ExcelExportFormViewModel(model, () => changedInvoked = true);
|
|
|
|
// Act
|
|
sut.DebugWriteToFile = true; // Same value
|
|
|
|
// Assert
|
|
changedInvoked.ShouldBeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_ThrowsOnNullModel()
|
|
{
|
|
// Act & Assert
|
|
Should.Throw<ArgumentNullException>(() => new ExcelExportFormViewModel(null!, () => { }));
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_ThrowsOnNullOnChanged()
|
|
{
|
|
// Arrange
|
|
var model = new ExcelExportSection();
|
|
|
|
// Act & Assert
|
|
Should.Throw<ArgumentNullException>(() => new ExcelExportFormViewModel(model, null!));
|
|
}
|
|
}
|