Exemple #1
0
        public void WorkUnitQueryParameter_Operator_UnknownOperatorsThrowExceptionOnStringValue()
        {
            var parameter = new WorkUnitQueryParameter {
                Operator = (WorkUnitQueryOperator)Int32.MaxValue
            };

            Assert.Throws <InvalidOperationException>(() => parameter.GetOperatorString());
        }
Exemple #2
0
        public void WorkUnitQueryParameter_DefaultConstructor_HasPropertyValues()
        {
            var parameter = new WorkUnitQueryParameter();

            Assert.AreEqual(WorkUnitRowColumn.ProjectID, parameter.Column);
            Assert.AreEqual(WorkUnitQueryOperator.Equal, parameter.Operator);
            Assert.AreEqual("=", parameter.GetOperatorString());
        }
Exemple #3
0
        public void WorkUnitQueryParameter_Value_IntegerBehavior()
        {
            var parameter = new WorkUnitQueryParameter();

            parameter.Value = 6900;
            Assert.AreEqual("6900", parameter.Value);
            parameter.Value = null;
            Assert.IsNull(parameter.Value);
        }
Exemple #4
0
        public void WorkUnitQueryParameter_Value_DateTimeBehavior()
        {
            var parameter = new WorkUnitQueryParameter();

            parameter.Value = new DateTime(2000, 1, 1);
            Assert.AreEqual(new DateTime(2000, 1, 1), parameter.Value);
            parameter.Value = null;
            Assert.IsNull(parameter.Value);
        }
Exemple #5
0
        public void WorkUnitQueryParameter_Value_StringBehavior()
        {
            var parameter = new WorkUnitQueryParameter();

            parameter.Value = "Value";
            Assert.AreEqual("Value", parameter.Value);
            parameter.Value = null;
            Assert.IsNull(parameter.Value);
        }
Exemple #6
0
        public void WorkUnitQueryParameter_Operator_OperatorsHaveStringValue()
        {
            var parameter = new WorkUnitQueryParameter();

            foreach (WorkUnitQueryOperator op in Enum.GetValues(typeof(WorkUnitQueryOperator)))
            {
                parameter.Operator = op;
                Console.WriteLine(parameter.GetOperatorString());
            }
        }
Exemple #7
0
        private static PetaPoco.Sql BuildWhereCondition(PetaPoco.Sql sql, WorkUnitQueryParameter parameter)
        {
            string format = "[{0}] {1} @0";

            if (parameter.Column.Equals(WorkUnitRowColumn.Assigned) ||
                parameter.Column.Equals(WorkUnitRowColumn.Finished))
            {
                format = "datetime([{0}]) {1} datetime(@0)";
            }
            sql = sql.Append(String.Format(CultureInfo.InvariantCulture, format,
                                           ColumnNameOverrides.ContainsKey(parameter.Column) ? ColumnNameOverrides[parameter.Column] : parameter.Column.ToString(),
                                           parameter.GetOperatorString()), parameter.Value);
            return(sql);
        }
Exemple #8
0
 public WorkUnitQuery AddParameter(WorkUnitQueryParameter parameter)
 {
     Parameters.Add(parameter);
     return(this);
 }