public void EitherArrayNullShouldNotBeEqual()
        {
            bool[] a = new[] { true, false, true }, b = null;

            Assert.That(ArrayHelper.ArrayEquals(a, b), Is.False);
            Assert.That(ArrayHelper.ArrayEquals(b, a), Is.False);
        }
Esempio n. 2
0
        public virtual IDbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes)
        {
            /* NH:
             * The code inside this block was added for a strange behaviour
             * discovered using Firebird (some times for us is external issue).
             * The problem is that batchCommandSql as a value, batchCommand is not null
             * BUT batchCommand.CommandText is null (I don't know who clear it)
             */
            bool forceCommandRecreate = batchCommand == null || string.IsNullOrEmpty(batchCommand.CommandText);

            /****************************************/
            if (sql.Equals(batchCommandSql) &&
                ArrayHelper.ArrayEquals(parameterTypes, batchCommandParameterTypes) && !forceCommandRecreate)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("reusing command " + batchCommand.CommandText);
                }
            }
            else
            {
                batchCommand               = PrepareCommand(type, sql, parameterTypes);   // calls ExecuteBatch()
                batchCommandSql            = sql;
                batchCommandParameterTypes = parameterTypes;
            }

            return(batchCommand);
        }
Esempio n. 3
0
 private bool HasSameParameters(CacheableResultTransformer other)
 {
     return(_tupleLength == other._tupleLength &&
            _tupleSubsetLength == other._tupleSubsetLength &&
            ArrayHelper.ArrayEquals(_includeInTuple, other._includeInTuple) &&
            ArrayHelper.ArrayEquals(_includeInTransformIndex, other._includeInTransformIndex));
 }
        public void ArraysShouldBeEqual()
        {
            var a = new[] { 1, 2, 3, 4 };
            var b = new[] { 1, 2, 3, 4 };

            Assert.That(ArrayHelper.ArrayEquals(a, b), Is.True);
            Assert.That(ArrayHelper.ArrayEquals(b, a), Is.True);
        }
Esempio n. 5
0
        public override bool IsEqual(object x, object y)
        {
            if (x == y)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            return(ArrayHelper.ArrayEquals(ToInternalFormat(x), ToInternalFormat(y)));
        }
        public virtual DbCommand PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes)
        {
            if (sql.Equals(_batchCommandSql) && ArrayHelper.ArrayEquals(parameterTypes, _batchCommandParameterTypes))
            {
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("reusing command {0}", _batchCommand.CommandText);
                }
            }
            else
            {
                _batchCommand               = PrepareCommand(type, sql, parameterTypes);   // calls ExecuteBatch()
                _batchCommandSql            = sql;
                _batchCommandParameterTypes = parameterTypes;
            }

            return(_batchCommand);
        }
        public virtual async Task <DbCommand> PrepareBatchCommandAsync(CommandType type, SqlString sql, SqlType[] parameterTypes, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            if (sql.Equals(_batchCommandSql) && ArrayHelper.ArrayEquals(parameterTypes, _batchCommandParameterTypes))
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug("reusing command " + _batchCommand.CommandText);
                }
            }
            else
            {
                _batchCommand               = await(PrepareCommandAsync(type, sql, parameterTypes, cancellationToken)).ConfigureAwait(false);    // calls ExecuteBatch()
                _batchCommandSql            = sql;
                _batchCommandParameterTypes = parameterTypes;
            }

            return(_batchCommand);
        }
Esempio n. 8
0
        public override bool Equals(Object o)
        {
            if (this == o)
            {
                return(true);
            }

            if (o == null || typeof(CacheableResultTransformer) != o.GetType())
            {
                return(false);
            }

            var that = (CacheableResultTransformer)o;

            return(_tupleLength == that._tupleLength &&
                   _tupleSubsetLength == that._tupleSubsetLength &&
                   ArrayHelper.ArrayEquals(_includeInTuple, that._includeInTuple) &&
                   ArrayHelper.ArrayEquals(_includeInTransformIndex, that._includeInTransformIndex));
        }
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            var that = obj as NativeSQLQuerySpecification;

            if (that == null)
            {
                return(false);
            }

            // NH-3956: hashcode inequality rules out equality, but hashcode equality is not enough.
            // Code taken back from 8e92af3f and amended according to NH-1931.
            return
                (hashCode == that.hashCode &&
                 queryString.Equals(that.queryString) &&
                 CollectionHelper.SetEquals(querySpaces, that.querySpaces) &&
                 ArrayHelper.ArrayEquals(sqlQueryReturns, that.sqlQueryReturns));
        }
Esempio n. 10
0
 public void NullArraysShouldBeEqual()
 {
     bool[] a = null, b = null;
     Assert.That(ArrayHelper.ArrayEquals(a, b), Is.True);
 }