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); }
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()); }