public void Format_WhenNotInclusive_ExpectNotInclusiveQuery() { // Arrange var lessThanFormatter = new LessThanFormatter(); var node = new LessThanOperator { Name = "ColumnName", Value = 23, Inclusive = false, Statement = "ColumnName:[23,*]", }; // Act var stopwatch = Stopwatch.StartNew(); var sqlDataResponse = lessThanFormatter.Format(node, 0); stopwatch.Stop(); // Assert this.WriteTimeElapsed(stopwatch); Assert.That(sqlDataResponse.Sql, Is.EqualTo("ColumnName < @ColumnName0")); Assert.That(sqlDataResponse.Params.First().Value, Is.EqualTo(23)); }
public void Format_WhenBinaryNode_ExpectWhereStatement() { // Arrange var equalsFormatter = new EqualsFormatter(); var lessThanFormatter = new LessThanFormatter(); var greaterThanFormatter = new GreaterThanFormatter(); var rangeFormatter = new RangeFormatter(); var whereFormatter = new WhereFormatter( equalsFormatter, lessThanFormatter, greaterThanFormatter, rangeFormatter); var whereNode2 = new WhereNode { Statement = new WhereStatement { Value = new EqualsOperator { Name = "FirstName", IsNot = false, Statement = "FirstName:asd", Value = "asd", }, }, }; var whereNode = new WhereNode { Statement = new WhereStatement { Value = new EqualsOperator { Name = "ColumnName", IsNot = false, Statement = "ColumnName:bob", Value = "bob", }, }, Conjunctive = Conjunctives.And, Next = whereNode2, }; // Act var stopwatch = Stopwatch.StartNew(); var sqlDataResponse = whereFormatter.Format(whereNode); stopwatch.Stop(); // Assert this.WriteTimeElapsed(stopwatch); Console.WriteLine(sqlDataResponse.Sql); }
/// <summary> /// Creates this instance. /// </summary> /// <returns>The <see cref="IFormatter"/>.</returns> public static IFormatterFactory Create() { var orderByFormatter = new OrderByFormatter(); var pageFormatter = new PostgresPageFormatter(); var equalsFormatter = new EqualsFormatter(); var lessThanFormatter = new LessThanFormatter(); var greaterThanFormatter = new GreaterThanFormatter(); var rangeFormatter = new RangeFormatter(); var whereFormatter = new WhereFormatter( equalsFormatter, lessThanFormatter, greaterThanFormatter, rangeFormatter); var standardFormatter = new Formatter(orderByFormatter, pageFormatter, whereFormatter); var countCteFormatter = new CountCteFormatter(orderByFormatter, pageFormatter, whereFormatter); return(new FormatterFactory(standardFormatter, countCteFormatter)); }