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);
            }
        }
Exemplo n.º 3
0
 public void TestConstructeur()
 {
     using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
         SqlServerCommand command = new SqlServerCommand("test", "procTest");
         Assert.IsNotNull(command.CreateParameter());
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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]);
            }
        }