Пример #1
0
        public void ShowWhere()
        {
            int exists    = 0;
            int notExists = 0;

            using (new Timer("ShowWhere"))
                using (JetConnection connection = JetDatabaseFixture.GetConnection())
                {
                    connection.Open();
                    for (int i = 0; i < 1000; i++)
                    {
                        if (TableExistsShowWhere(connection, $"Employees_{i % 500}"))
                        {
                            exists++;
                        }
                        else
                        {
                            notExists++;
                        }
                    }
                }

            Assert.AreEqual(600, exists);
            Assert.AreEqual(400, notExists);
        }
Пример #2
0
        public void Cleanup()
        {
            using (JetConnection connection = JetDatabaseFixture.GetConnection())
            {
                connection.Open();

                for (int i = 0; i < 300; i++)
                {
                    string sql = $@"DROP TABLE [Employees_{i}]";
                    connection.CreateCommand(sql).ExecuteNonQuery();
                }
            }
        }
Пример #3
0
        public void Initialize()
        {
            using (JetConnection connection = JetDatabaseFixture.GetConnection())
            {
                connection.Open();

                for (int i = 0; i < 300; i++)
                {
                    string sql = $@"
CREATE TABLE [Employees_{i}] (
	[EmployeeID] int IDENTITY (1, 1) NOT NULL ,
	[LastName] varchar (20) NOT NULL ,
	[FirstName] varchar (10) NOT NULL ,
	[Title] varchar (30) NULL ,
	[TitleOfCourtesy] varchar (25) NULL ,
	[BirthDate] datetime NULL ,
	[HireDate] datetime NULL ,
	[Address] varchar (60) NULL ,
	[City] varchar (15) NULL ,
	[Region] varchar (15) NULL ,
	[PostalCode] varchar (10) NULL ,
	[Country] varchar (15) NULL ,
	[HomePhone] varchar (24) NULL ,
	[Extension] varchar (4) NULL ,
	[Photo] image NULL ,
	[Notes] text NULL ,
	[ReportsTo] int NULL ,
	[PhotoPath] varchar (255) NULL ,
	CONSTRAINT [PK_Employees] PRIMARY KEY
	(
		[EmployeeID]
	)
);
CREATE  INDEX [LastName] ON [Employees_{i}]([LastName]);
CREATE  INDEX [PostalCode] ON [Employees_{i}]([PostalCode]);
";

                    connection.CreateCommand(sql).ExecuteNonQuery();
                }
            }
        }
        public void Where_False_Test_DisposeConnection()
        {
            const int cycles = 60;


            using (new Timer($"Select {cycles} Where 1=2 get table structure (Dispose connection)"))
            {
                for (int i = 0; i < cycles; i++)
                {
                    using (var connection = JetDatabaseFixture.GetConnection())
                    {
                        connection.Open();
                        var reader      = connection.CreateCommand("Select * from employees where 1=2").ExecuteReader(CommandBehavior.KeyInfo);
                        var schemaTable = reader.GetSchemaTable();
                        reader.Dispose();
                        // ReSharper disable once PossibleNullReferenceException
                        schemaTable.Dispose();
                    }
                }
            }

            using (new Timer($"Select {cycles} Top 1 get table structure (Dispose connection)"))
            {
                for (int i = 0; i < cycles; i++)
                {
                    using (var connection = JetDatabaseFixture.GetConnection())
                    {
                        connection.Open();
                        var reader      = connection.CreateCommand("Select top 1 * from employees").ExecuteReader(CommandBehavior.KeyInfo);
                        var schemaTable = reader.GetSchemaTable();
                        reader.Dispose();
                        // ReSharper disable once PossibleNullReferenceException
                        schemaTable.Dispose();
                    }
                }
            }
        }
Пример #5
0
 static public void AssemblyInitialize(TestContext testContext)
 {
     JetDatabaseFixture.CreateAndSeedIfNotExists();
     // Enabling show sql statements can change performances
     //JetConfiguration.ShowSqlStatements = true;
 }