<commit_before>using System;
using System.Data;
using Moq;
using NUnit.Framework;
using Sharp.Data;
using Sharp.Data.Providers;

namespace Sharp.Tests.Data {

    [TestFixture]
    public class DatabaseTests {
    
        protected DataParameterCollectionFake _allParameters;
        protected Mock<IDbCommand> _cmd;
        protected Mock<IDbConnection> _connection;
        protected Database _db;
        protected Mock<IDbDataParameter> _parameter1, _parameter2;
        protected Mock<IDataProvider> _provider;
        protected string _sql = "foo";
        protected Mock<IDbTransaction> _transaction;
    	protected Mock<Dialect> _dialect;

        [SetUp]
        public void SetUp() {
			_dialect = new Mock<Dialect>();
            _provider = new Mock<IDataProvider>();
            _connection = new Mock<IDbConnection>();
            _transaction = new Mock<IDbTransaction>();
            _cmd = new Mock<IDbCommand>();
            _parameter1 = new Mock<IDbDataParameter>();
            _parameter2 = new Mock<IDbDataParameter>();
            _parameter1.SetupAllProperties();
            _parameter2.SetupAllProperties();

            _allParameters = new DataParameterCollectionFake();

            _connection.Setup(p => p.BeginTransaction()).Returns(_transaction.Object);
            _connection.Setup(p => p.CreateCommand()).Returns(_cmd.Object);
            _provider.Setup(p => p.GetConnection()).Returns(_connection.Object);
            _provider.Setup(p => p.GetParameter())
                .Returns(() => _parameter1.Object)
                .Callback(() => _provider.Setup(p => p.GetParameter())
                                    .Returns(_parameter2.Object));

            _cmd.SetupGet(p => p.Parameters).Returns(_allParameters);

            _db = new Database(_provider.Object, "");
        }

        [Test]
        public void Can_execute_sql_with_parameters() {
            _cmd.Setup(p => p.ExecuteNonQuery()).Returns(1);

            Assert.AreEqual(1, _db.ExecuteSql(_sql, "par1", "par2"));
            Assert.AreEqual(2, _cmd.Object.Parameters.Count);
        }

        [Test]
        public void Can_execute_sql_without_parameters() {
            _cmd.Setup(p => p.ExecuteNonQuery()).Returns(1);<commit_msg>Test fix<commit_after>using System;
using System.Data;
using Moq;
using NUnit.Framework;
using Sharp.Data;
using Sharp.Data.Providers;

namespace Sharp.Tests.Data {

    [TestFixture]
    public class DatabaseTests {

        protected DataParameterCollectionFake _allParameters;
        protected Mock<IDbCommand> _cmd;
        protected Mock<IDbConnection> _connection;
        protected Database _db;
        protected Mock<IDbDataParameter> _parameter1, _parameter2;
        protected Mock<IDataProvider> _provider;
        protected string _sql = "foo";
        protected Mock<IDbTransaction> _transaction;
        protected Mock<Dialect> _dialect;

        [SetUp]
        public void SetUp() {
            _dialect = new Mock<Dialect>();
            _provider = new Mock<IDataProvider>();
            _connection = new Mock<IDbConnection>();
            _transaction = new Mock<IDbTransaction>();
            _cmd = new Mock<IDbCommand>();
            _parameter1 = new Mock<IDbDataParameter>();
            _parameter2 = new Mock<IDbDataParameter>();
            _parameter1.SetupAllProperties();
            _parameter2.SetupAllProperties();

            _allParameters = new DataParameterCollectionFake();

            _connection.Setup(p => p.BeginTransaction()).Returns(_transaction.Object);
            _connection.Setup(p => p.CreateCommand()).Returns(_cmd.Object);
            _provider.Setup(p => p.GetConnection()).Returns(_connection.Object);
            _provider.Setup(p => p.GetParameter())
                .Returns(() => _parameter1.Object)
                .Callback(() => _provider.Setup(p => p.GetParameter())
                                         .Returns(_parameter2.Object));

            _provider.Setup(p => p.GetParameter(It.IsAny<In>())).Returns(() => _parameter1.Object)
                                  .Callback(() => _provider.Setup(p => p.GetParameter())
                                  .Returns(_parameter2.Object));

            _cmd.SetupGet(p => p.Parameters).Returns(_allParameters);

            _db = new Database(_provider.Object, "");
        }

        [Test]
        public void Can_execute_sql_with_parameters() {
            _cmd.Setup(p => p.ExecuteNonQuery()).Returns(1);

            Assert.AreEqual(1, _db.ExecuteSql(_sql, "par1", "par2"));
            Assert.AreEqual(2, _cmd.Object.Parameters.Count);
        }

        [Test]
        public void Can_execute_sql_without_parameters() {
            _cmd.Setup(p => p.ExecuteNonQuery()).Returns(1);
{'fraction_non_alphanumeric': 0.11595117845117846, 'fraction_numerical': 0.006313131313131313, 'mean_word_length': 2.3925767309064954, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3289499', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1231, 'n_words': 235}