6e2decd21f
Implement LdapFormViewModel for editing LDAP configuration section with properties for ServerUrlsText, GroupDn, SearchBase, ConnectionTimeoutSeconds, UseFakeAuth, and AdminBypassUsersText. Array properties use newline-separated text with StringSplitOptions.RemoveEmptyEntries | TrimEntries for splitting.
119 lines
3.4 KiB
C#
119 lines
3.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
|
|
{
|
|
CriteriaSheetPassword = "criteriaPass123",
|
|
DataSheetPassword = "dataPass456",
|
|
MaxRowsPerSheet = 500000,
|
|
DefaultDateFormat = "MM/dd/yyyy",
|
|
DebugWriteToFile = true,
|
|
DebugOutputDirectory = "/tmp/debug",
|
|
TimezoneId = "America/New_York",
|
|
TimezoneAbbreviation = "ET"
|
|
};
|
|
|
|
// Act
|
|
var sut = new ExcelExportFormViewModel(model, () => { });
|
|
|
|
// Assert
|
|
sut.CriteriaSheetPassword.ShouldBe("criteriaPass123");
|
|
sut.DataSheetPassword.ShouldBe("dataPass456");
|
|
sut.MaxRowsPerSheet.ShouldBe(500000);
|
|
sut.DefaultDateFormat.ShouldBe("MM/dd/yyyy");
|
|
sut.DebugWriteToFile.ShouldBeTrue();
|
|
sut.DebugOutputDirectory.ShouldBe("/tmp/debug");
|
|
sut.TimezoneId.ShouldBe("America/New_York");
|
|
sut.TimezoneAbbreviation.ShouldBe("ET");
|
|
}
|
|
|
|
[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 PropertyChange_InvokesOnChanged()
|
|
{
|
|
// Arrange
|
|
var model = new ExcelExportSection();
|
|
var changedInvoked = false;
|
|
var sut = new ExcelExportFormViewModel(model, () => changedInvoked = true);
|
|
|
|
// Act
|
|
sut.TimezoneId = "Europe/London";
|
|
|
|
// 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!));
|
|
}
|
|
}
|