public void TestSetItemByName()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                SqlServerCommand             command = new SqlServerCommand("test", "procTest");
                SqlServerParameterCollection coll    = command.Parameters;
                SqlServerParameter           param   = command.CreateParameter();
                param.ParameterName = "Param1";
                coll.Add(param);
                Assert.IsTrue(coll.Contains(param));
                Assert.IsTrue(coll.Contains("Param1"));
                Assert.AreEqual(param, coll[0]);
                Assert.AreEqual(param, coll["Param1"]);
                Assert.AreEqual(param, ((IList)coll)[0]);

                param = command.CreateParameter();
                param.ParameterName = "Param2";
                coll["Param1"]      = param;

                Assert.AreEqual(1, coll.Count);
                Assert.IsTrue(coll.Contains(param));
                Assert.IsTrue(coll.Contains("Param2"));
                Assert.AreEqual(param, coll[0]);
                Assert.AreEqual(param, coll["Param2"]);
                Assert.AreEqual(param, ((IList)coll)[0]);
            }
        }
        public void TestIListRemove()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                SqlServerCommand             command = new SqlServerCommand("test", "procTest");
                SqlServerParameterCollection coll    = command.Parameters;
                SqlServerParameter           param   = command.CreateParameter();
                param.ParameterName = "Param1";
                coll.Add(param);
                Assert.IsTrue(coll.Contains(param));
                Assert.IsTrue(coll.Contains("Param1"));
                Assert.AreEqual(1, coll.Count);

                SqlServerParameter param2 = command.CreateParameter();
                param2.ParameterName = "Param2";
                coll.Add(param2);
                Assert.IsTrue(coll.Contains(param2));
                Assert.IsTrue(coll.Contains("Param2"));
                Assert.AreEqual(2, coll.Count);

                ((IList)coll).Remove(param);
                Assert.IsTrue(coll.Contains(param2));
                Assert.IsTrue(coll.Contains("Param2"));
                Assert.IsFalse(coll.Contains(param));
                Assert.IsFalse(coll.Contains("Param1"));
                Assert.AreEqual(1, coll.Count);
            }
        }
示例#3
0
 public void TestConstructeur()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand command = new SqlServerCommand("test", "procTest");
         Assert.IsNotNull(command.CreateParameter());
     }
 }
示例#4
0
 public void TestIsNull()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand command = new SqlServerCommand("test", "procTest");
         IDataParameter   param   = command.CreateParameter();
         Assert.IsTrue(param.IsNullable);
     }
 }
示例#5
0
 public void TestParameterName()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand   command = new SqlServerCommand("test", "procTest");
         SqlServerParameter param   = command.CreateParameter();
         param.ParameterName = "Param1";
         Assert.AreEqual("Param1", param.ParameterName);
     }
 }
示例#6
0
 public void TestDirection()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand   command = new SqlServerCommand("test", "procTest");
         SqlServerParameter param   = command.CreateParameter();
         param.Direction = ParameterDirection.Output;
         Assert.AreEqual(ParameterDirection.Output, param.Direction);
     }
 }
示例#7
0
 public void TestDbType()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand   command = new SqlServerCommand("test", "procTest");
         SqlServerParameter param   = command.CreateParameter();
         param.DbType = DbType.String;
         Assert.AreEqual(DbType.String, param.DbType);
     }
 }
示例#8
0
 public void TestValueDbNull()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand   command = new SqlServerCommand("test", "procTest");
         SqlServerParameter param   = command.CreateParameter();
         param.Value = DBNull.Value;
         Assert.IsNull(param.Value);
     }
 }
示例#9
0
 public void TestSourceVersion()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand command = new SqlServerCommand("test", "procTest");
         IDataParameter   param   = command.CreateParameter();
         param.SourceVersion = DataRowVersion.Proposed;
         Assert.AreEqual(DataRowVersion.Proposed, param.SourceVersion);
     }
 }
示例#10
0
 public void TestSourceColumn()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand command = new SqlServerCommand("test", "procTest");
         IDataParameter   param   = command.CreateParameter();
         param.SourceColumn = "Column1";
         Assert.AreEqual("Column1", param.SourceColumn);
     }
 }
示例#11
0
 public void TestPrecision()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand   command = new SqlServerCommand("test", "procTest");
         SqlServerParameter param   = command.CreateParameter();
         param.DbType    = DbType.Decimal;
         param.Precision = 5;
         Assert.AreEqual(0, param.Precision);
     }
 }
 public void TestAdd()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand             command = new SqlServerCommand("test", "procTest");
         SqlServerParameterCollection coll    = command.Parameters;
         SqlServerParameter           param   = command.CreateParameter();
         param.ParameterName = "Param1";
         coll.Add(param);
         Assert.IsTrue(coll.Contains(param));
         Assert.IsTrue(coll.Contains("Param1"));
         Assert.IsTrue(((IList)coll).Contains(param));
     }
 }
        public void TestICollectionCopyTo()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                SqlServerCommand             command = new SqlServerCommand("test", "procTest");
                SqlServerParameterCollection coll    = command.Parameters;
                SqlServerParameter           param   = command.CreateParameter();
                param.ParameterName = "Param1";
                coll.Add(param);
                Assert.IsTrue(coll.Contains(param));
                Assert.IsTrue(coll.Contains("Param1"));
                Assert.IsTrue(((IList)coll).Contains(param));

                object[] array = new object[1];
                ((ICollection)coll).CopyTo(array, 0);
                Assert.AreEqual(param, array[0]);
            }
        }