Esempio n. 1
0
        public void DbCommandTimeoutConnectionTransactionSameNullParameters()
        {
            int                commandTimeout = _faker.Random.Int();
            string             queryText      = "Select * From Users";
            CustomDbConnection connection     = new CustomDbConnection()
            {
                ConnectionString = _connectionString
            };
            CustomDbTransaction transaction = connection.BeginTransaction() as CustomDbTransaction;
            CommandType         type        = _faker.PickRandom <CommandType>();
            DbCommand           command     = _factory.GetDbCommand(type, queryText, connection, null, commandTimeout, transaction);

            Assert.IsNotNull(command);
            Assert.IsNotNull(command.Parameters);
            Assert.IsNotNull(command.Connection);
            Assert.IsNotNull(command.Transaction);
            Assert.IsNotNull(command.CommandText);
            Assert.AreEqual(queryText, command.CommandText);
            Assert.AreEqual(type, command.CommandType);
            Assert.AreEqual(commandTimeout, command.CommandTimeout);
            Assert.AreEqual(connection, command.Connection);
            Assert.AreEqual(transaction, command.Transaction);
            Assert.IsTrue(command.Parameters.Count == 0);
            Assert.IsInstanceOf(typeof(CustomDbTransaction), command.Transaction);
            Assert.IsInstanceOf(typeof(CustomDbConnection), command.Connection);
            Assert.IsInstanceOf(typeof(CustomDbCommand), command);
            Assert.IsInstanceOf(typeof(CustomDbParameterCollection), command.Parameters);
        }
Esempio n. 2
0
        public void DbCommandTimeoutConnectionTransactionParametersSame()
        {
            List <CustomDbParameter> parameters = new List <CustomDbParameter>()
            {
                new CustomDbParameter()
                {
                    ParameterName = "@Param3"
                },
                new CustomDbParameter()
                {
                    ParameterName = "@Param2"
                },
                new CustomDbParameter()
                {
                    ParameterName = "@Param1"
                }
            };
            int                commandTimeout = _faker.Random.Int();
            string             queryText      = "Select * From Users";
            CustomDbConnection connection     = new CustomDbConnection()
            {
                ConnectionString = _connectionString
            };
            CustomDbTransaction transaction = connection.BeginTransaction() as CustomDbTransaction;
            CommandType         type        = _faker.PickRandom <CommandType>();
            DbCommand           command     = _factory.GetDbCommand(type, queryText, connection, parameters, commandTimeout, transaction);

            Assert.IsNotNull(command);
            Assert.IsNotNull(command.Parameters);
            Assert.IsNotNull(command.Connection);
            Assert.IsNotNull(command.Transaction);
            Assert.IsNotNull(command.CommandText);
            Assert.AreEqual(queryText, command.CommandText);
            Assert.AreEqual(type, command.CommandType);
            Assert.AreEqual(commandTimeout, command.CommandTimeout);
            Assert.AreEqual(connection, command.Connection);
            Assert.AreEqual(transaction, command.Transaction);
            Assert.IsTrue(parameters.Count == command.Parameters.Count);
            Assert.IsInstanceOf(typeof(CustomDbTransaction), command.Transaction);
            Assert.IsInstanceOf(typeof(CustomDbConnection), command.Connection);
            Assert.IsInstanceOf(typeof(CustomDbCommand), command);
            Assert.IsInstanceOf(typeof(CustomDbParameterCollection), command.Parameters);

            //Assert all parameters are equal
            for (int i = 0; i < command.Parameters.Count; i++)
            {
                DbParameter parameter = command.Parameters[i];

                Assert.IsInstanceOf(typeof(CustomDbParameter), parameter);
                Assert.AreEqual(parameters[i], parameter);
            }
        }
Esempio n. 3
0
        public void DbCommandTimeoutConnectionTransactionSame()
        {
            int commandTimeout            = _faker.Random.Int();
            CustomDbConnection connection = new CustomDbConnection()
            {
                ConnectionString = _connectionString
            };
            CustomDbTransaction transaction = connection.BeginTransaction() as CustomDbTransaction;
            DbCommand           command     = _factory.GetDbCommand(connection, transaction, commandTimeout);

            Assert.IsNotNull(command);
            Assert.AreEqual(commandTimeout, command.CommandTimeout);
            Assert.AreEqual(connection, command.Connection);
            Assert.AreEqual(transaction, command.Transaction);
            Assert.IsInstanceOf(typeof(CustomDbTransaction), command.Transaction);
            Assert.IsInstanceOf(typeof(CustomDbConnection), command.Connection);
            Assert.IsInstanceOf(typeof(CustomDbCommand), command);
        }