Esempio n. 1
0
        public void ToString_WithJoinTable()
        {
            var schema    = "fromSchema";
            var name      = "fromTable";
            var tableName = new EntityName(schema, name);

            var fromColumn1 = "fromCol1";
            var fromColumn2 = "fromCol2";
            var fromAlias2  = "fromAlias2";
            var columns     = new IItemName[]  {
                new ItemName(fromColumn1),
                new ColumnName(fromColumn2, fromAlias2)
            };
            var fromTable = new FromTable(tableName, columns);

            IEntityName joinTableName = new EntityName("joinTable");

            IItemName[] selectColumns = new IItemName[2] {
                new ItemName("joinTblCol1"), new ItemName("joinTblCol2")
            };
            var joinTable = new JoinTable(joinTableName, selectColumns);

            fromTable.Join(joinTable);

            var selectClause = fromTable.GetSelectClause();
            var testString   = $"[{schema}].[{name}].[{fromColumn1}], [{schema}].[{name}].[{fromColumn2}] as [{fromAlias2}], {joinTableName}.{selectColumns[0]}, {joinTableName}.{selectColumns[1]}";

            Assert.AreEqual(testString, selectClause);
        }
Esempio n. 2
0
        public void ToString_WithJoinTable_NoJTSelectColumns()
        {
            var schema    = "fromSchema";
            var name      = "fromTable";
            var tableName = new EntityName(schema, name);

            var fromColumn1 = "fromCol1";
            var fromColumn2 = "fromCol2";
            var fromAlias2  = "fromAlias2";
            var columns     = new IColumnName[]  {
                new ColumnName(fromColumn1),
                new ColumnName(fromColumn2, fromAlias2)
            };
            IFromTable fromTable = new FromTable(tableName, columns);

            IEntityName joinTableName = new EntityName("joinTable");
            var         joinTable     = new JoinTable(joinTableName);

            fromTable.Join(joinTable);

            var selectClause = fromTable.ToString();
            var testString   = $"select [{schema}].[{name}].[{fromColumn1}], [{schema}].[{name}].[{fromColumn2}] as [{fromAlias2}]\r\nfrom [{schema}].[{name}]\r\n";

            Assert.AreEqual(testString.TrimEnd(), selectClause.TrimEnd());
        }
Esempio n. 3
0
        public void Constructor_Name()
        {
            var name      = "name";
            var tableName = new EntityName(name);

            Assert.AreEqual(name, tableName.Name);
        }
Esempio n. 4
0
        private JoinColumn GetJoinColumn(string table, string column)
        {
            EntityName tableName  = table;
            ItemName   columnName = column;

            return(new JoinColumn(tableName, columnName));
        }
Esempio n. 5
0
        public void InterfaceToString_NameProvided()
        {
            var         name      = "name";
            IEntityName tableName = new EntityName(name);

            Assert.AreEqual($"[{name}]", tableName.ToString());
        }
Esempio n. 6
0
        public void ToStringTest()
        {
            EntityName tableName  = "tableName";
            ItemName   columnName = "columnName";
            JoinColumn joinColumn = new JoinColumn(tableName, columnName);

            Assert.AreEqual($"{tableName}.{columnName}", joinColumn.ToString());
        }
Esempio n. 7
0
        public void Constructor_EmptyColumnsArgument()
        {
            IEntityName tableName = new EntityName("tableName");

            IItemName[] selectColumns = new IItemName[0];

            var table = new FromTable(tableName, selectColumns);
        }
Esempio n. 8
0
        public void InterfaceToString_SchemaAndNameProvided()
        {
            var        schema    = "schema";
            var        name      = "name";
            EntityName tableName = new EntityName(schema, name);

            Assert.AreEqual($"[{schema}].[{name}]", tableName.ToString());
        }
Esempio n. 9
0
        public void ImplicitStringOperator_NameProvided()
        {
            var        name            = "name";
            EntityName tableName       = new EntityName(name);
            string     tableNameString = tableName;

            Assert.AreEqual($"[{name}]", tableNameString);
        }
Esempio n. 10
0
        public void Constructor_NullColumnsArgument()
        {
            IEntityName tableName = new EntityName("joinTable");
            var         table     = new JoinTable(tableName, null);

            Assert.AreEqual(tableName, table.TableName);
            Assert.IsNull(table.Columns);
        }
Esempio n. 11
0
        public void Constructor_OneNullColumnArgument()
        {
            IEntityName tableName = new EntityName("joinTable");

            IItemName[] selectColumns = new IItemName[2] {
                new ItemName("joinColumn"), null
            };
            var table = new JoinTable(tableName, selectColumns);
        }
Esempio n. 12
0
        public void Constructor_EmptyColumnsArgument()
        {
            IEntityName tableName = new EntityName("joinTable");

            IItemName[] selectColumns = new IItemName[0];
            var         table         = new JoinTable(tableName, selectColumns);

            Assert.AreEqual(0, table.Columns.Length);
        }
Esempio n. 13
0
        public void ImplicitStringOperator_SchemaAndNameProvided()
        {
            var        schema          = "schema";
            var        name            = "name";
            EntityName tableName       = new EntityName(schema, name);
            string     tableNameString = tableName;

            Assert.AreEqual($"[{schema}].[{name}]", tableNameString);
        }
Esempio n. 14
0
        public void Constructor_SchemaName()
        {
            var schema    = "schema";
            var name      = "name";
            var tableName = new EntityName(schema, name);

            Assert.AreEqual(name, tableName.Name);
            Assert.AreEqual(schema, tableName.Schema);
        }
Esempio n. 15
0
        public void Constructor()
        {
            EntityName tableName  = "tableName";
            ItemName   columnName = "columnName";
            JoinColumn joinColumn = new JoinColumn(tableName, columnName);

            Assert.AreEqual(tableName, joinColumn.TableName);
            Assert.AreEqual(columnName, joinColumn.ColumnName);
        }
Esempio n. 16
0
        public void Constructor_OneNullColumnArgument()
        {
            IEntityName tableName = new EntityName("tableName");

            IItemName[] selectColumns = new IItemName[2] {
                new ColumnName("name", "alias"), null
            };

            var table = new FromTable(tableName, selectColumns);
        }
Esempio n. 17
0
        public void Equatable()
        {
            EntityName tableName   = "tableName";
            ItemName   columnName  = "columnName";
            JoinColumn joinColumn1 = new JoinColumn(tableName, columnName);
            JoinColumn joinColumn2 = new JoinColumn(tableName, columnName);

            Assert.AreEqual(joinColumn1, joinColumn2);
            Assert.IsTrue(joinColumn1 == joinColumn2);
        }
Esempio n. 18
0
        public void ToString_NoJoinColumns()
        {
            IEntityName tableName = new EntityName("joinTable");

            IItemName[] selectColumns = new IItemName[1] {
                new ItemName("selectColumn")
            };
            var table = new JoinTable(tableName, selectColumns);

            Assert.AreEqual(string.Empty, table.ToString());
        }
Esempio n. 19
0
        public void Constructor_WithColumns()
        {
            IEntityName tableName = new EntityName("joinTable");

            IItemName[] selectColumns = new IItemName[1] {
                new ItemName("joinColumn")
            };
            var table = new JoinTable(tableName, selectColumns);

            Assert.AreEqual(tableName, table.TableName);
            Assert.AreEqual(selectColumns, table.Columns);
        }
Esempio n. 20
0
        public void ToString_WithSchemaAndOneColumn()
        {
            var schema    = "fromSchema";
            var name      = "fromTable";
            var tableName = new EntityName(schema, name);

            var fromColumn1 = "fromCol1";
            var columns     = new IItemName[] { new ItemName(fromColumn1) };
            var ft          = new FromTable(tableName, columns);

            Assert.AreEqual($"select [{schema}].[{name}].[{fromColumn1}]\r\nfrom [{schema}].[{name}]\r\n", ft.ToString());
        }
Esempio n. 21
0
        public void Constructor()
        {
            IEntityName tableName = new EntityName("tableName");

            IItemName[] selectColumns = new IItemName[1] {
                new ColumnName("name", "alias")
            };
            var table = new FromTable(tableName, selectColumns);

            Assert.AreEqual(tableName, table.TableName);
            Assert.AreEqual(selectColumns, table.Columns);
            Assert.IsNull(table.JoinTables);
        }
Esempio n. 22
0
        public void AddJoinColumn()
        {
            IEntityName tableName = new EntityName("joinTable");

            IItemName[] selectColumns = new IItemName[1] {
                new ItemName("joinColumn")
            };
            var        table         = new JoinTable(tableName, selectColumns);
            EntityName fromTableName = "fromTable";
            ItemName   leftColumn    = "leftJoinColumn";
            ItemName   rightColumn   = "rightJoinColumn";

            table.AddJoinColumn(fromTableName, leftColumn, rightColumn);
        }
Esempio n. 23
0
        public void ToString_WithoutSchema()
        {
            var name      = "fromTable";
            var tableName = new EntityName(name);

            var fromColumn1 = "fromCol1";
            var fromColumn2 = "fromCol2";
            var fromAlias2  = "fromAlias2";
            var columns     = new IItemName[]  {
                new ItemName(fromColumn1),
                new ColumnName(fromColumn2, fromAlias2)
            };
            var ft = new FromTable(tableName, columns);

            Assert.AreEqual($"select [{name}].[{fromColumn1}], [{name}].[{fromColumn2}] as [{fromAlias2}]\r\nfrom [{name}]\r\n", ft.ToString());
        }
Esempio n. 24
0
        public void ToString_OneJoinColumn()
        {
            IEntityName tableName = new EntityName("joinTable");

            IItemName[] selectColumns = new IItemName[1] {
                new ItemName("selectColumn")
            };
            var        table         = new JoinTable(tableName, selectColumns);
            EntityName fromTableName = "fromTable";
            ItemName   leftColumn1   = "leftJoinColumn";
            ItemName   rightColumn1  = "rightJoinColumn";

            table.AddJoinColumn(fromTableName, leftColumn1, rightColumn1);

            var testString = $"join {tableName} on {fromTableName}.{leftColumn1}{RelationalOperators.Equal.ToSqlString()}{table.TableName}.{rightColumn1}";

            Assert.AreEqual(testString, table.ToString());
        }
Esempio n. 25
0
 public void Constructor_SchemaProvided_NameStringEmptyArgument()
 {
     string schema    = "schema";
     string name      = string.Empty;
     var    tableName = new EntityName(schema, name);
 }
Esempio n. 26
0
 public void Constructor_SchemaProvided_NameNullArgument()
 {
     string schema    = "schema";
     string name      = null;
     var    tableName = new EntityName(schema, name);
 }
Esempio n. 27
0
 public void Constructor_SchemaStringEmptyArgument()
 {
     string schema    = string.Empty;
     var    name      = "name";
     var    tableName = new EntityName(schema, name);
 }
Esempio n. 28
0
 public void Constructor_SchemaNullArgument()
 {
     string schema    = null;
     var    name      = "name";
     var    tableName = new EntityName(schema, name);
 }
Esempio n. 29
0
 public void Constructor_NameStringEmptyArgument()
 {
     string name      = string.Empty;
     var    tableName = new EntityName(name);
 }
Esempio n. 30
0
 public void Constructor_NameNullArgument()
 {
     string name      = null;
     var    tableName = new EntityName(name);
 }