public void WorkUnitQuery_Compare_IsGreaterThanNullQuery() { var query = new WorkUnitQuery(); Assert.IsTrue(query.CompareTo(null) > 0); Assert.IsTrue(query > null); }
public void WorkUnitQuery_DefaultConstructor_HasPropertyValues() { var query = new WorkUnitQuery(); Assert.AreEqual(String.Empty, query.Name); Assert.AreEqual(0, query.Parameters.Count); }
public void WorkUnitQuery_Compare_AreEqual() { var query1 = new WorkUnitQuery(); var query2 = new WorkUnitQuery(); Assert.IsTrue(query1.CompareTo(query2) == 0); Assert.IsTrue(query1 == query2); }
public void WorkUnitQuery_Compare_IsGreaterThanNull() { var query1 = new WorkUnitQuery(); var query2 = new WorkUnitQuery { Name = null }; Assert.IsTrue(query1.CompareTo(query2) > 0); Assert.IsTrue(query1 > query2); }
public void WorkUnitQuery_Compare_IsLessThan() { var query1 = new WorkUnitQuery(); var query2 = new WorkUnitQuery { Name = "Name" }; Assert.IsTrue(query1.CompareTo(query2) < 0); Assert.IsTrue(query1 < query2); }
public void WorkUnitQuery_Compare_NullAreEqual() { var query1 = new WorkUnitQuery { Name = null }; var query2 = new WorkUnitQuery { Name = null }; Assert.AreEqual(0, query1.CompareTo(query2)); }
private static void ValidateTestQueryParameters(IList <WorkUnitQuery> list) { for (int i = 0; i < 5; i++) { WorkUnitQuery workUnitQuery = list[i]; Assert.AreEqual("Test" + i, workUnitQuery.Name); Assert.AreEqual(WorkUnitRowColumn.Name, workUnitQuery.Parameters[0].Column); Assert.AreEqual(WorkUnitQueryOperator.Equal, workUnitQuery.Parameters[0].Operator); Assert.AreEqual("Test" + i, workUnitQuery.Parameters[0].Value); } }
public void WorkUnitQuery_Compare_AreNotEqual() { var query1 = new WorkUnitQuery { Name = "A" }; var query2 = new WorkUnitQuery { Name = "B" }; Assert.IsTrue(query1.CompareTo(query2) != 0); Assert.IsTrue(query1 != query2); }
internal static PetaPoco.Sql ToSql(this WorkUnitQuery query) { if (query.Parameters.Count == 0) { return(null); } bool appendAnd = false; PetaPoco.Sql sql = PetaPoco.Sql.Builder.Append("WHERE "); foreach (var field in query.Parameters) { sql = sql.Append(appendAnd ? "AND " : String.Empty); sql = BuildWhereCondition(sql, field); appendAnd = true; } return(appendAnd ? sql.Append(" ORDER BY [ID] ASC") : null); }
public void WorkUnitQuery_DeepClone_ReturnsCopyOfQuery() { // Arrange var query = new WorkUnitQuery("Test") .AddParameter(WorkUnitRowColumn.Name, WorkUnitQueryOperator.Equal, "Test Instance") .AddParameter(WorkUnitRowColumn.Assigned, WorkUnitQueryOperator.GreaterThan, new DateTime(2000, 1, 1)); // Act var copy = query.DeepClone(); // Assert Assert.AreNotSame(query, copy); Assert.AreEqual(query.Name, copy.Name); Assert.AreEqual(query.Parameters.Count, copy.Parameters.Count); for (int i = 0; i < query.Parameters.Count; i++) { Assert.AreEqual(query.Parameters[i].Column, copy.Parameters[i].Column); Assert.AreEqual(query.Parameters[i].Operator, copy.Parameters[i].Operator); Assert.AreEqual(query.Parameters[i].Value, copy.Parameters[i].Value); } }
internal static PetaPoco.Sql Append(this PetaPoco.Sql sql, WorkUnitQuery query) { return(sql.Append(query.ToSql())); }