コード例 #1
0
        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]);
            }
        }
コード例 #2
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);
     }
 }
コード例 #12
0
 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));
     }
 }
コード例 #13
0
        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]);
            }
        }