public void ConnectToDB_SqlServer(string connectionName, SqlConnectionStringBuilder sqlConnectionString) { databaseController.Connections.Should().NotContainKey(connectionName, $"Connection \"{connectionName}\" already exists"); var connection = new SqlServerClient(); connection.Create(sqlConnectionString).Should().BeTrue(); connection.IsConnectAlive().Should().BeTrue(); databaseController.Connections.TryAdd(connectionName, (connection, TypeOfAccess.Local, sqlConnectionString.ConnectTimeout)); }
public void IsConnectAlive_CorrectConnectionParams_ReturnFalse() { var mockSqlProvider = new Mock <ISqlProvider>(); var client = new SqlServerClient(); mockSqlProvider.Setup(c => c.IsConnectAlive()).Returns(false); client._provider = mockSqlProvider.Object; client.IsConnectAlive().Should().BeFalse(); }
public void ConnectToDB_SqlServer(string connectionName, DbConnectionParams connectionParams) { var(isValid, results) = Validate.ValidateModel(connectionParams); isValid.Should().BeTrue(Message.CreateMessage(results)); databaseController.Connections.Should().NotContainKey(connectionName, $"Connection \"{connectionName}\" already exists"); var connection = new SqlServerClient(); connection.Create(connectionParams).Should().BeTrue(); connection.IsConnectAlive().Should().BeTrue(); databaseController.Connections.TryAdd(connectionName, (connection, connectionParams.Timeout)); }
public static void Before(VariableController variableController, DatabaseController databaseController) { var connectionsStringBuilder = new SqlConnectionStringBuilder { DataSource = variableController.GetVariableValueText("SOURCE"), InitialCatalog = variableController.GetVariableValueText("DATABASE"), UserID = variableController.GetVariableValueText("LOGIN"), Password = variableController.GetVariableValueText("PASSWORD"), ConnectTimeout = 60 }; var connection = new SqlServerClient(); connection.Create(connectionsStringBuilder); connection.IsConnectAlive(); databaseController.Connections.TryAdd("QA", (connection, typeOfAccess: Molder.Infrastructures.TypeOfAccess.Global, connectionsStringBuilder.ConnectTimeout)); }