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:
+37
@@ -14,6 +14,7 @@ public class ConnectionStringEntryViewModelTests
|
||||
Name = "TestConnection",
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
SqlServerPort = 1434,
|
||||
Database = "TestDb",
|
||||
UserId = "testuser",
|
||||
Password = "testpass",
|
||||
@@ -30,6 +31,7 @@ public class ConnectionStringEntryViewModelTests
|
||||
sut.Name.ShouldBe("TestConnection");
|
||||
sut.Provider.ShouldBe(ConnectionProvider.SqlServer);
|
||||
sut.Server.ShouldBe("localhost");
|
||||
sut.SqlServerPort.ShouldBe(1434);
|
||||
sut.Database.ShouldBe("TestDb");
|
||||
sut.UserId.ShouldBe("testuser");
|
||||
sut.Password.ShouldBe("testpass");
|
||||
@@ -179,4 +181,39 @@ public class ConnectionStringEntryViewModelTests
|
||||
// Assert
|
||||
sut.ServerDisplay.ShouldBe("-");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SqlServerPort_PropertyChange_UpdatesModel()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringEntry();
|
||||
var changedInvoked = false;
|
||||
var sut = new ConnectionStringEntryViewModel(model, () => changedInvoked = true);
|
||||
|
||||
// Act
|
||||
sut.SqlServerPort = 1434;
|
||||
|
||||
// Assert
|
||||
model.SqlServerPort.ShouldBe(1434);
|
||||
changedInvoked.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SqlServerPort_PropertyChange_UpdatesGeneratedConnectionString()
|
||||
{
|
||||
// Arrange
|
||||
var model = new ConnectionStringEntry
|
||||
{
|
||||
Provider = ConnectionProvider.SqlServer,
|
||||
Server = "localhost",
|
||||
Database = "TestDb"
|
||||
};
|
||||
var sut = new ConnectionStringEntryViewModel(model, () => { });
|
||||
|
||||
// Act
|
||||
sut.SqlServerPort = 1434;
|
||||
|
||||
// Assert
|
||||
sut.GeneratedConnectionString.ShouldContain("Server=localhost,1434");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -75,10 +75,11 @@ public class ConnectionStringsFormViewModelTests
|
||||
// Act
|
||||
var sut = new ConnectionStringsFormViewModel(model, _secureStoreManager, () => { }, _dialogService, _connectionTestService);
|
||||
|
||||
// Assert
|
||||
// Assert - port stays embedded in server name, not parsed into SqlServerPort
|
||||
sut.Connections.Count.ShouldBe(1);
|
||||
sut.Connections[0].Provider.ShouldBe(ConnectionProvider.SqlServer);
|
||||
sut.Connections[0].Server.ShouldBe("localhost,1434");
|
||||
sut.Connections[0].SqlServerPort.ShouldBeNull();
|
||||
sut.Connections[0].Database.ShouldBe("ScopingTool");
|
||||
sut.Connections[0].UserId.ShouldBe("scopingapp");
|
||||
sut.Connections[0].Password.ShouldBe("pass");
|
||||
|
||||
Reference in New Issue
Block a user