feat(configmanager): add dedicated SQL Server port control
Add SqlServerPort property to connection string editor for explicit port configuration, replacing the need to embed port in server name (e.g., localhost,1434). The port control generates the comma-separated format in the connection string but does not parse it back when loading existing connection strings.
This commit is contained in:
@@ -107,6 +107,7 @@ public class ConnectionStringEntryTests
|
||||
entry.Name.ShouldBe(string.Empty);
|
||||
entry.Provider.ShouldBe(ConnectionProvider.Generic);
|
||||
entry.Server.ShouldBeNull();
|
||||
entry.SqlServerPort.ShouldBeNull();
|
||||
entry.Database.ShouldBeNull();
|
||||
entry.UserId.ShouldBeNull();
|
||||
entry.Password.ShouldBeNull();
|
||||
@@ -119,4 +120,70 @@ public class ConnectionStringEntryTests
|
||||
entry.ServiceName.ShouldBeNull();
|
||||
entry.RawConnectionString.ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateConnectionString_SqlServer_WithPort_IncludesPortInServer()
|
||||
{
|
||||
// Arrange
|
||||
var entry = new ConnectionStringEntry
|
||||
{
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
SqlServerPort = 1434,
|
||||
Database = "TestDb",
|
||||
UserId = "sa",
|
||||
Password = "secret123"
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = entry.GenerateConnectionString();
|
||||
|
||||
// Assert
|
||||
result.ShouldContain("Server=localhost,1434");
|
||||
result.ShouldContain("Database=TestDb");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateConnectionString_SqlServer_WithoutPort_NoPortInServer()
|
||||
{
|
||||
// Arrange
|
||||
var entry = new ConnectionStringEntry
|
||||
{
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
SqlServerPort = null,
|
||||
Database = "TestDb",
|
||||
UserId = "sa",
|
||||
Password = "secret123"
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = entry.GenerateConnectionString();
|
||||
|
||||
// Assert
|
||||
result.ShouldContain("Server=localhost;");
|
||||
result.ShouldNotContain("Server=localhost,");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateConnectionString_SqlServer_WithZeroPort_NoPortInServer()
|
||||
{
|
||||
// Arrange
|
||||
var entry = new ConnectionStringEntry
|
||||
{
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
SqlServerPort = 0,
|
||||
Database = "TestDb",
|
||||
UserId = "sa",
|
||||
Password = "secret123"
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = entry.GenerateConnectionString();
|
||||
|
||||
// Assert
|
||||
result.ShouldContain("Server=localhost;");
|
||||
result.ShouldNotContain("Server=localhost,");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user