GetParameterValueAsObject() private method

Converts the parameter value into an object, based on its specified parameter type (see the ParameterType enumeration for more detail). For instance, a number type will be converted to a Decimal object.
private GetParameterValueAsObject ( ) : object
return object
Esempio n. 1
0
        public void Test_GetParameterValueAsObject_WhenDateType_TomorrowString_ShouldReturnYesterday()
        {
            //---------------Set up test pack-------------------
            Parameter param = new Parameter("prop", "table", "field", "=", "tomorrow", ParameterType.Date);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            DateTime parameterValueAsObject = (DateTime)param.GetParameterValueAsObject();
            //---------------Test Result -----------------------
            Assert.IsNotNull(parameterValueAsObject);
            Assert.AreEqual(DateTimeToday.Value.AddDays(1), parameterValueAsObject);
        }
Esempio n. 2
0
        public void TestParameterTypes()
        {
            Parameter param = new Parameter("prop", "table", "field", "=", "value", ParameterType.String);
            Assert.AreEqual("value", param.GetParameterValueAsObject());

            param = new Parameter("prop", "table", "field", "=", "true", ParameterType.Bool);
            Assert.AreEqual(true, param.GetParameterValueAsObject());

            param = new Parameter("prop", "table", "field", "=", "2007/2/1", ParameterType.Date);
            Assert.AreEqual(new DateTime(2007, 2, 1), param.GetParameterValueAsObject());

            param = new Parameter("prop", "table", "field", "=", "2.1", ParameterType.Number);
            Assert.AreEqual(2.1, param.GetParameterValueAsObject());
        }