Esempio n. 1
0
 public void DbCommandExtensions_Unit_AddParameterWithValue1_AllValidDbTypes()
 {
     String name = "@Name";
     Object value = "Value";
     foreach (DbType type in DbCommandExtensionsTests.GetDbTypes()) {
         using (IDbCommand command = new SqlCommand()) {
             IDbDataParameter returnValue = command.AddParameterWithValue(name, type, value);
             Assert.IsNotNull(returnValue);
             Assert.AreEqual(1, command.Parameters.Count);
             Assert.AreEqual(returnValue, command.Parameters[0]);
             Assert.AreEqual(name, returnValue.ParameterName);
             Assert.AreEqual(value, returnValue.Value);
             Assert.AreEqual(ParameterDirection.Input, returnValue.Direction);
         }
     }
 }
Esempio n. 2
0
        public void DbCommandExtensions_Unit_AddParameterWithValue1_NameNull()
        {
            using (IDbCommand command = new SqlCommand()) {
                String name = null;
                DbType type = DbType.String;
                Object value = "Value";

                IDbDataParameter returnValue = command.AddParameterWithValue(name, type, value);
                Assert.IsNotNull(returnValue);
                Assert.AreEqual(1, command.Parameters.Count);
                Assert.AreEqual(returnValue, command.Parameters[0]);
                Assert.AreEqual(type, returnValue.DbType);
                Assert.AreEqual(value, returnValue.Value);
                Assert.AreEqual(ParameterDirection.Input, returnValue.Direction);
            }
        }
Esempio n. 3
0
        public void DbCommandExtensions_Unit_AddParameterWithValue1_InvalidDbType()
        {
            using (IDbCommand command = new SqlCommand()) {
                String name = "@Name";
                DbType type = (DbType)(-1);
                Object value = "Value";

                command.AddParameterWithValue(name, type, value);
            }
        }
Esempio n. 4
0
        public void DbCommandExtensions_Unit_AddParameterWithValue4_ValueNull()
        {
            using (IDbCommand command = new SqlCommand()) {
                String name = "@Name";
                DbType type = DbType.String;
                Int32 size = 100;
                Object value = null;
                ParameterDirection direction = ParameterDirection.InputOutput;

                IDbDataParameter returnValue = command.AddParameterWithValue(name, type, size, value, direction);
                Assert.IsNotNull(returnValue);
                Assert.AreEqual(1, command.Parameters.Count);
                Assert.AreEqual(returnValue, command.Parameters[0]);
                Assert.AreEqual(name, returnValue.ParameterName);
                Assert.AreEqual(type, returnValue.DbType);
                Assert.AreEqual(DBNull.Value, returnValue.Value);
                Assert.AreEqual(direction, returnValue.Direction);
            }
        }
Esempio n. 5
0
        public void DbCommandExtensions_Unit_AddParameterWithValue4_InvalidParameterDirection()
        {
            using (IDbCommand command = new SqlCommand()) {
                String name = "@Name";
                DbType type = DbType.String;
                Int32 size = 100;
                Object value = "Value";
                ParameterDirection direction = (ParameterDirection)0;

                command.AddParameterWithValue(name, type, size, value, direction);
            }
        }
Esempio n. 6
0
 public void DbCommandExtensions_Unit_AddParameterWithValue4_AllValidParameterDirections()
 {
     String name = "@Name";
     DbType type = DbType.String;
     Int32 size = 100;
     Object value = "Value";
     foreach (ParameterDirection direction in Enum.GetValues(typeof(ParameterDirection))) {
         using (IDbCommand command = new SqlCommand()) {
             IDbDataParameter returnValue = command.AddParameterWithValue(name, type, size, value, direction);
             Assert.IsNotNull(returnValue);
             Assert.AreEqual(1, command.Parameters.Count);
             Assert.AreEqual(returnValue, command.Parameters[0]);
             Assert.AreEqual(name, returnValue.ParameterName);
             Assert.AreEqual(type, returnValue.DbType);
             Assert.AreEqual(value, returnValue.Value);
             Assert.AreEqual(direction, returnValue.Direction);
         }
     }
 }
Esempio n. 7
0
        public void DbCommandExtensions_Unit_AddParameterWithValue3_InvalidDbType()
        {
            using (IDbCommand command = new SqlCommand()) {
                String name = "@Name";
                DbType type = (DbType)(-1);
                Object value = "Value";
                ParameterDirection direction = ParameterDirection.InputOutput;

                command.AddParameterWithValue(name, type, value, direction);
            }
        }