public void ItShouldAllowASingleEquals() { const string finalText = "WHERE {0} = @{0}{1}"; var whereClause = new Where() [ FirstColumn.IsEqualTo(1) ]; var whereItems = WhereDeconstruction.RetrieveTheWhereItemUniqueNames(whereClause).First(); whereClause .CreateSql() .Should() .Be(string.Format(finalText, FirstColumn, whereItems)); }
public void ItShouldAllowAnOr() { const string finalText = "WHERE {0} = @{0}{2} OR ({1} = @{1}{3})"; var whereClause = new Where() [ FirstColumn.IsEqualTo(1), Also.Or(SecondColumn.IsEqualTo(1)) ]; var whereItems = WhereDeconstruction.RetrieveTheWhereItemUniqueNames(whereClause); whereClause .CreateSql() .Should() .Be(string.Format(finalText, FirstColumn, SecondColumn, whereItems[0], whereItems[1])); }
public void ItShouldAllowCompoundExpressions() { const string finalText = "WHERE {0} = @{0}{3} AND ({1} = @{1}{4}) OR ({2} = @{2}{5})"; ThirdColumn = "ThirdColumn"; var whereClause = new Where() [ FirstColumn.IsEqualTo(1), Also.And(SecondColumn.IsEqualTo(1)), Also.Or(ThirdColumn.IsEqualTo(1)) ]; var whereItems = WhereDeconstruction.RetrieveTheWhereItemUniqueNames(whereClause); whereClause .CreateSql() .Should() .Be(string.Format(finalText, FirstColumn, SecondColumn, ThirdColumn, whereItems[0], whereItems[1], whereItems[2])); }