예제 #1
0
 public void TestExecuteNonQuery()
 {
     using (var command = new TestDataCommand())
     {
         command.ConnectionString = "sqlConnectionString";
         var num = command.ExecuteNonQuery(_Students[2]);
         Assert.Equal(3, num);
         num = 0;
         num = command.ExecuteNonQuery();
         Assert.Equal(3, num);
     }
 }
예제 #2
0
 public void TestInParamsNullable()
 {
     using (var command = new TestDataCommand())
     {
         command.Text             = "update top(1) Name = @Name where Age in @Age";
         command.ConnectionString = "sqlConnectionString";
         var num = command.ExecuteNonQuery(new { Name = "1", Age = new List <int?>()
                                                 {
                                                     1, 2, null
                                                 } });
         var com = command.Connection.Command;
         Assert.Equal("update top(1) Name = @Name where Age in (@Age0,@Age1,@Age2)", com.CommandText);
         Assert.Equal("1", com.Parameters["@Name"].Value);
         for (int i = 0; i < 3; i++)
         {
             var p = com.Parameters[$"@Age{i}"];
             if (i + 1 != 3)
             {
                 Assert.Equal(i + 1, p.Value);
             }
             else
             {
                 Assert.Equal(DBNull.Value, p.Value);
             }
             Assert.Equal(DbType.Int32, p.DbType);
         }
     }
 }