Files
Joseph Doherty 1fc7792cd1 refactor(configmanager): rename UI project and split test projects
Rename ConfigManager to ConfigManager.Ui to match the Core/CLI/UI project
structure, and split the monolithic test project into Core.Tests,
Cli.Tests, and Ui.Tests to align with the source project organization.
2026-01-28 10:24:36 -05:00

61 lines
1.7 KiB
C#

using JdeScoping.ConfigManager.Core.Models;
using JdeScoping.ConfigManager.Ui.ViewModels.Forms;
namespace JdeScoping.ConfigManager.Ui.Tests.ViewModels.Forms;
public class LdapFormViewModelTests
{
[Fact]
public void Constructor_InitializesFromModel()
{
// Arrange
var model = new LdapSection
{
ServerUrls = ["ldap://server1.local", "ldap://server2.local"],
GroupDn = "CN=Admins,DC=corp",
SearchBase = "DC=corp,DC=local",
UseFakeAuth = true
};
// Act
var sut = new LdapFormViewModel(model, () => { });
// Assert
sut.ServerUrlsText.ShouldBe("ldap://server1.local\nldap://server2.local");
sut.GroupDn.ShouldBe("CN=Admins,DC=corp");
sut.SearchBase.ShouldBe("DC=corp,DC=local");
sut.UseFakeAuth.ShouldBeTrue();
}
[Fact]
public void ServerUrlsText_SplitsIntoArray()
{
// Arrange
var model = new LdapSection();
var sut = new LdapFormViewModel(model, () => { });
// Act
sut.ServerUrlsText = "ldap://a.local\nldap://b.local\nldap://c.local";
// Assert
model.ServerUrls.Length.ShouldBe(3);
model.ServerUrls[0].ShouldBe("ldap://a.local");
model.ServerUrls[2].ShouldBe("ldap://c.local");
}
[Fact]
public void AdminBypassUsersText_SplitsIntoArray()
{
// Arrange
var model = new LdapSection();
var sut = new LdapFormViewModel(model, () => { });
// Act
sut.AdminBypassUsersText = "admin\nservice_account";
// Assert
model.AdminBypassUsers.Length.ShouldBe(2);
model.AdminBypassUsers[0].ShouldBe("admin");
}
}