public void TestAllStatementBuilderPartialFunctions() { StatementBuilder statementBuilder = new StatementBuilder() .Select("Name, Id") .From("Geo_Target") .Where("Targetable = :targetable") .OrderBy("Id DESC") .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT) .Offset(0) .AddValue("targetable", true) .IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT) .RemoveLimitAndOffset(); Assert.AreEqual(null, statementBuilder.GetOffset()); Statement expectedStatement = new Statement(); expectedStatement.query = "SELECT Name, Id FROM Geo_Target" + " WHERE Targetable = :targetable ORDER BY Id DESC"; String_ValueMapEntry targetableEntry = new String_ValueMapEntry(); targetableEntry.key = "targetable"; BooleanValue targetableValue = new BooleanValue(); targetableValue.value = true; targetableEntry.value = targetableValue; expectedStatement.values = new String_ValueMapEntry[] { targetableEntry }; Assert.True(StatementsAreEqual(expectedStatement, statementBuilder.ToStatement())); }
/// <summary> /// Adds a new value to the list of query parameters. /// </summary> /// <param name="key">The parameter name.</param> /// <param name="value">The parameter value.</param> /// <returns>The statement builder, for chaining method calls.</returns> private StatementBuilder AddValue(string key, Value value) { String_ValueMapEntry queryValue = new String_ValueMapEntry(); queryValue.key = key; queryValue.value = value; valueEntries.Add(queryValue); return(this); }
private static bool StringValueMapEntriesAreEqual(String_ValueMapEntry entry1, String_ValueMapEntry entry2) { return(String.Equals(entry1.key, entry2.key) && ValuesAreEqual(entry1.value, entry2.value)); }
/// <summary> /// Adds a new value to the list of query parameters. /// </summary> /// <param name="key">The parameter name.</param> /// <param name="value">The parameter value.</param> /// <returns>The statement builder, for chaining method calls.</returns> private StatementBuilder AddValue(string key, Value value) { String_ValueMapEntry queryValue = new String_ValueMapEntry(); queryValue.key = key; queryValue.value = value; valueEntries.Add(queryValue); return this; }
private static bool StringValueMapEntriesAreEqual(String_ValueMapEntry entry1, String_ValueMapEntry entry2) { return String.Equals(entry1.key, entry2.key) && ValuesAreEqual(entry1.value, entry2.value); }
public void TestAllStatementBuilderPartialFunctions() { StatementBuilder statementBuilder = new StatementBuilder() .Select("Name, Id") .From("Geo_Target") .Where("Targetable = :targetable") .OrderBy("Id DESC") .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT) .Offset(0) .AddValue("targetable", true) .IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT) .RemoveLimitAndOffset(); Assert.AreEqual(null, statementBuilder.GetOffset()); Statement expectedStatement = new Statement(); expectedStatement.query = "SELECT Name, Id FROM Geo_Target" + " WHERE Targetable = :targetable ORDER BY Id DESC"; String_ValueMapEntry targetableEntry = new String_ValueMapEntry(); targetableEntry.key = "targetable"; BooleanValue targetableValue = new BooleanValue(); targetableValue.value = true; targetableEntry.value = targetableValue; expectedStatement.values = new String_ValueMapEntry[] {targetableEntry}; Assert.True(StatementsAreEqual(expectedStatement, statementBuilder.ToStatement())); }