Пример #1
0
        public void ObjectReference_With_Incorrect_Input()
        {
            // Arrange
            String  expectedResult = "";
            DataRow row            = (new DataTable()).NewRow();

            // Act
            KeyValuePair <String, String> result =
                SQLProviderHelper.CreateObjectReference(row);

            // Assert
            Assert.Equal(expectedResult, result.Value);
            Assert.Equal("", result.Key);
        }
Пример #2
0
        public void ObjectReference_With_1_Component()
        {
            // Arrange
            String  expectedResult = "Table";
            DataRow row            = CreateDataRow();

            row["TABLE_NAME"] = "Table";

            // Act
            KeyValuePair <String, String> result =
                SQLProviderHelper.CreateObjectReference(row);

            // Assert
            Assert.Equal(expectedResult, result.Value);
            Assert.Equal(row["TABLE_NAME"], result.Key);
        }
Пример #3
0
        public void ObjectReference_With_All_3_Components()
        {
            // Arrange
            String  expectedResult = "Database.Schema.Table";
            DataRow row            = CreateDataRow();

            row["TABLE_CATALOG"] = "Database";
            row["TABLE_SCHEMA"]  = "Schema";
            row["TABLE_NAME"]    = "Table";

            // Act
            KeyValuePair <String, String> result =
                SQLProviderHelper.CreateObjectReference(row);

            // Assert
            Assert.Equal(expectedResult, result.Value);
            Assert.Equal(row["TABLE_NAME"], result.Key);
        }
        /// <summary>
        /// List the tables and views in the SQL Connection
        /// </summary>
        /// <returns>The list of tables and views in the SQL Connection</returns>
        public override List <KeyValuePair <String, String> > ObjectList()
        {
            // Set up the result
            List <KeyValuePair <String, String> > result =
                new List <KeyValuePair <String, String> >()
            {
            };

            // Is the data provider connected? If not don't attempt to read the schema
            if (this.Connected)
            {
                // Get the raw tables list
                DataTable rawTables = this.sqlConnection.GetSchema("Tables");
                foreach (DataRow row in rawTables.Rows)
                {
                    result.Add(SQLProviderHelper.CreateObjectReference(row));
                }
            }

            // Send the result back to the caller
            return(result);
        }