Exemple #1
0
        public void TestWithMappingTypeOfListChanges()
        {
            ColumnMapping.ParameterDataTypes.AddMapper(new DataTypeMapperForList());

            ConnectionStateCase.ForEach(c =>
            {
                var command = c.CreateCommand
                              (
                    sql: "SELECT * FROM dbo.Beer WHERE Style IN (@listItem)",
                    parameters: new
                {
                    listItem = new List <string>
                    {
                        "Lager",
                        "IPA"
                    }
                },
                    commandType: CommandType.Text,
                    commandTimeout: 10,
                    transaction: null
                              );

                Assert.AreEqual(((IDataParameter)command.Parameters[0]).DbType, DbType.AnsiString);
            });
        }
Exemple #2
0
 public void TestAutoClose()
 {
     ConnectionStateCase.ForEach(c =>
     {
         var result = c.Query <Beer>(Beer.SelectAllProc);
         Beer.VerifyAll(result);
     });
 }
Exemple #3
0
 public void TestAutoClose()
 {
     ConnectionStateCase.ForEach(c =>
     {
         var parameters = new { p = 1 };
         var result     = c.ExecuteScalarSql <int>("SELECT @p", parameters);
         Assert.AreEqual(parameters.p, result);
     });
 }
        public void TestAutoClose()
        {
            ConnectionStateCase.ForEach(c =>
            {
                var result = c.QuerySqlAsync("SELECT @p", new { p = 1 }, reader => 1).Result;

                Assert.AreEqual(1, result);
            });
        }
        public void TestAutoClose()
        {
            ConnectionStateCase.ForEach(c =>
            {
                var recordCount = c.ExecuteSql("SELECT @p", new { p = 1 });

                Assert.AreEqual(-1, recordCount);
            });
        }
Exemple #6
0
 public void TestAutoClose()
 {
     ConnectionStateCase.ForEach(c =>
     {
         var input = new InOutParameters {
             In = 5
         };
         var result = c.InsertSqlAsync("SELECT @In", input).Result;
     });
 }
Exemple #7
0
 public void TestForceClose()
 {
     ConnectionStateCase.ForEach(c =>
     {
         bool wasOpen    = c.State == ConnectionState.Open;
         var recordCount = c.ExecuteScalarSql <int>("SELECT @p", new { p = 1 }, closeConnection: true);
         Assert.AreEqual(ConnectionState.Closed, c.State);
         if (wasOpen)
         {
             c.Open();
         }
     });
 }
Exemple #8
0
        public void TestForceClose()
        {
            ConnectionStateCase.ForEach(c =>
            {
                bool wasOpen = c.State == ConnectionState.Open;

                c.Query <Beer>(Beer.SelectAllProc, commandBehavior: CommandBehavior.CloseConnection);

                Assert.AreEqual(ConnectionState.Closed, c.State);
                if (wasOpen)
                {
                    c.Open();
                }
            });
        }
        public void TestForceClose()
        {
            ConnectionStateCase.ForEach(c =>
            {
                bool wasOpen = c.State == ConnectionState.Open;

                var result = c.QuerySqlAsync("SELECT @p", new { p = 1 }, reader => 1, commandBehavior: CommandBehavior.CloseConnection).Result;

                Assert.AreEqual(ConnectionState.Closed, c.State);
                if (wasOpen)
                {
                    c.Open();
                }
            });
        }
Exemple #10
0
        public void TestWithMappingTypeDoesNotChange()
        {
            ColumnMapping.ParameterDataTypes.AddMapper(new DataTypeMapper2());

            ConnectionStateCase.ForEach(c =>
            {
                var command = c.CreateCommand
                              (
                    sql: "SELECT * FROM dbo.Beer WHERE Style = @changeMyType",
                    parameters: new { changeMyType = "Lager" },
                    commandType: CommandType.Text,
                    commandTimeout: 10,
                    transaction: null
                              );

                Assert.AreEqual(((IDataParameter)command.Parameters[0]).DbType, DbType.String);
            });
        }
Exemple #11
0
        public void TestForceClose()
        {
            ConnectionStateCase.ForEach(c =>
            {
                bool wasOpen = c.State == ConnectionState.Open;

                var input = new InOutParameters {
                    In = 5
                };
                var recordCount = c.InsertSqlAsync("SELECT @In", input, commandBehavior: CommandBehavior.CloseConnection).Result;

                Assert.AreEqual(ConnectionState.Closed, c.State);
                if (wasOpen)
                {
                    c.Open();
                }
            });
        }