Ejemplo 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);
        }
Ejemplo 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());
        }
Ejemplo n.º 3
0
        public void Constructor_Name()
        {
            var name      = "name";
            var tableName = new EntityName(name);

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

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

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

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

            IItemName[] selectColumns = new IItemName[0];

            var table = new FromTable(tableName, selectColumns);
        }
Ejemplo 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());
        }
Ejemplo n.º 9
0
        public void ImplicitStringOperator_NameProvided()
        {
            var        name            = "name";
            EntityName tableName       = new EntityName(name);
            string     tableNameString = tableName;

            Assert.AreEqual($"[{name}]", tableNameString);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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());
        }
Ejemplo 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);
        }
Ejemplo 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());
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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());
        }
Ejemplo 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());
        }
Ejemplo n.º 25
0
 public void Constructor_SchemaProvided_NameStringEmptyArgument()
 {
     string schema    = "schema";
     string name      = string.Empty;
     var    tableName = new EntityName(schema, name);
 }
Ejemplo n.º 26
0
 public void Constructor_SchemaProvided_NameNullArgument()
 {
     string schema    = "schema";
     string name      = null;
     var    tableName = new EntityName(schema, name);
 }
Ejemplo n.º 27
0
 public void Constructor_SchemaStringEmptyArgument()
 {
     string schema    = string.Empty;
     var    name      = "name";
     var    tableName = new EntityName(schema, name);
 }
Ejemplo n.º 28
0
 public void Constructor_SchemaNullArgument()
 {
     string schema    = null;
     var    name      = "name";
     var    tableName = new EntityName(schema, name);
 }
Ejemplo n.º 29
0
 public void Constructor_NameStringEmptyArgument()
 {
     string name      = string.Empty;
     var    tableName = new EntityName(name);
 }
Ejemplo n.º 30
0
 public void Constructor_NameNullArgument()
 {
     string name      = null;
     var    tableName = new EntityName(name);
 }