示例#1
0
        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));
        }
示例#2
0
        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();
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }