public void AddConcreteAnonymousValue()
        {
            DbAnonymousValue <string> expected = new DbAnonymousValue <string>("ParameterName", "AString");

            DbAutoFillHelper.AddParameterWithValue(command, expected);

            Assert.AreEqual(expected.Alias, command.Parameters[0].ParameterName);
            Assert.AreEqual(expected.GetValue(), command.Parameters[0].Value);
        }
Exemple #2
0
        public void SetParameters_NamedDbAnonymousValue_Test()
        {
            DbAnonymousValue <int> val = new DbAnonymousValue <int>(ANONYMOUS_VALUE_ALIAS, ANONYMOUS_SET_VALUE);

            DbAutoFillHelper.AddParameterWithValue(_command, val);

            Assert.IsTrue(_command.Parameters.Contains(ANONYMOUS_VALUE_ALIAS));
            Assert.AreEqual(_command.Parameters[ANONYMOUS_VALUE_ALIAS].Value, ANONYMOUS_SET_VALUE);
        }
        public void AddAnonymousValue()
        {
            const string expectedAlias = "Integer";
            const int    expectedValue = 50;

            DbAutoFillHelper.AddParameterWithValue(command, expectedAlias, expectedValue, null);

            Assert.AreEqual(expectedAlias, command.Parameters[0].ParameterName);
            Assert.AreEqual(expectedValue, command.Parameters[0].Value);
        }
        private void AddParametersWithValueToCommand(IDbCommand command, params object[] parameters)
        {
            if (parameters == null || parameters.Length == 0)
            {
                return;
            }

            foreach (object parameter in parameters)
            {
                if (parameter != null && false == (parameter is DBNull))
                {
                    IDbAnonymousValue anonymousParam = parameter as IDbAnonymousValue;

                    if (anonymousParam != null)
                    {
                        DbAutoFillHelper.AddParameterWithValue(command, anonymousParam.Alias, anonymousParam.GetValue(), null);
                    }
                    else
                    {
                        DbAutoFillHelper.FillDbParametersFromObject(command, parameter);
                    }
                }
            }
        }
Exemple #5
0
 public void SetParameters_NamedAnonymous_Raw_Test()
 {
     DbAutoFillHelper.AddParameterWithValue(_command, ANONYMOUS_VALUE_ALIAS, ANONYMOUS_SET_VALUE, null);
     Assert.IsTrue(_command.Parameters.Contains(ANONYMOUS_VALUE_ALIAS));
     Assert.AreEqual(_command.Parameters[ANONYMOUS_VALUE_ALIAS].Value, ANONYMOUS_SET_VALUE);
 }