feat(configmanager): add LdapFormViewModel
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.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
using JdeScoping.ConfigManager.Models;
|
||||
using JdeScoping.ConfigManager.ViewModels.Forms;
|
||||
|
||||
namespace JdeScoping.ConfigManager.Tests.ViewModels.Forms;
|
||||
|
||||
public class AuthFormViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_InitializesFromModel()
|
||||
{
|
||||
// Arrange
|
||||
var model = new AuthSection
|
||||
{
|
||||
CookieName = ".TestApp.Auth",
|
||||
CookieExpirationMinutes = 120
|
||||
};
|
||||
|
||||
// Act
|
||||
var sut = new AuthFormViewModel(model, () => { });
|
||||
|
||||
// Assert
|
||||
sut.CookieName.ShouldBe(".TestApp.Auth");
|
||||
sut.CookieExpirationMinutes.ShouldBe(120);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PropertyChange_UpdatesModelAndInvokesOnChanged()
|
||||
{
|
||||
// Arrange
|
||||
var model = new AuthSection();
|
||||
var changedInvoked = false;
|
||||
var sut = new AuthFormViewModel(model, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.CookieName = ".Custom.Cookie";
|
||||
|
||||
// Assert
|
||||
model.CookieName.ShouldBe(".Custom.Cookie");
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CookieExpirationMinutes_UpdatesModelAndInvokesOnChanged()
|
||||
{
|
||||
// Arrange
|
||||
var model = new AuthSection { CookieExpirationMinutes = 480 };
|
||||
var changedInvoked = false;
|
||||
var sut = new AuthFormViewModel(model, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.CookieExpirationMinutes = 60;
|
||||
|
||||
// Assert
|
||||
model.CookieExpirationMinutes.ShouldBe(60);
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PropertyChange_RaisesPropertyChanged()
|
||||
{
|
||||
// Arrange
|
||||
var model = new AuthSection();
|
||||
var sut = new AuthFormViewModel(model, () => { });
|
||||
var propertyChangedRaised = false;
|
||||
sut.PropertyChanged += (s, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(AuthFormViewModel.CookieName))
|
||||
propertyChangedRaised = true;
|
||||
};
|
||||
|
||||
// Act
|
||||
sut.CookieName = ".New.Cookie";
|
||||
|
||||
// Assert
|
||||
propertyChangedRaised.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullModel()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(() => new AuthFormViewModel(null!, () => { }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNullCallback()
|
||||
{
|
||||
// Act & Assert
|
||||
Should.Throw<ArgumentNullException>(() => new AuthFormViewModel(new AuthSection(), null!));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user