Exemple #1
0
        private static async Task Creates_physical_database_but_not_tables_test(bool async)
        {
            using (var testDatabase = OracleTestStore.GetOrCreate("CreateTest"))
            {
                var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(testDatabase);

                creator.EnsureDeleted();

                if (async)
                {
                    await creator.CreateAsync();
                }
                else
                {
                    creator.Create();
                }

                Assert.True(creator.Exists());

                if (testDatabase.ConnectionState != ConnectionState.Open)
                {
                    await testDatabase.OpenConnectionAsync();
                }

                Assert.Equal(
                    0, (await testDatabase.QueryAsync <string>(
                            "SELECT table_name FROM user_tables")).Count());
            }
        }
 private static async Task Returns_true_when_database_exists_and_has_any_tables_test(bool async)
 {
     using (var testDatabase = OracleTestStore.GetOrCreate("ExistingTables")
                               .InitializeOracle(null, t => new OracleDatabaseCreatorTest.BloggingContext(t), null))
     {
         var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(testDatabase);
         Assert.True(async ? await creator.HasTablesAsyncBase() : creator.HasTablesBase());
     }
 }
        private static async Task Throws_when_database_does_not_exist_test(bool async)
        {
            using (var testDatabase = OracleTestStore.GetOrCreate("NonExistingBlogging"))
            {
                var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(testDatabase);

                if (async)
                {
                    await Assert.ThrowsAsync <OracleException>(() => creator.DeleteAsync());
                }
                else
                {
                    Assert.Throws <OracleException>(() => creator.Delete());
                }
            }
        }
        private static async Task Throws_if_database_does_not_exist_test(bool async)
        {
            using (var testDatabase = OracleTestStore.GetOrCreate("NonExisting"))
            {
                var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(testDatabase);

                var errorNumber
                    = async
                        ? (await Assert.ThrowsAsync <OracleException>(() => creator.CreateTablesAsync())).Number
                        : Assert.Throws <OracleException>(() => creator.CreateTables()).Number;

                if (errorNumber != 233) // skip if no-process transient failure
                {
                    Assert.Equal(
                        1017, // Login failed error number
                        errorNumber);
                }
            }
        }
        private static async Task Throws_when_database_does_not_exist_test(bool async)
        {
            using (var testDatabase = OracleTestStore.GetOrCreate("NonExisting"))
            {
                var databaseCreator = OracleDatabaseCreatorTest.GetDatabaseCreator(testDatabase);
                await databaseCreator.ExecutionStrategyFactory.Create().ExecuteAsync(
                    databaseCreator,
                    async creator =>
                {
                    var errorNumber = async
                                ? (await Assert.ThrowsAsync <OracleException>(() => creator.HasTablesAsyncBase())).Number
                                : Assert.Throws <OracleException>(() => creator.HasTablesBase()).Number;

                    if (errorNumber != 233)         // skip if no-process transient failure
                    {
                        Assert.Equal(
                            1017,         // Login failed error number
                            errorNumber);
                    }
                });
            }
        }
        public override TestStore GetOrCreate(string storeName)
        {
            var oracleTestStore = OracleTestStore.GetOrCreate(Name, "Northwind.sql");

            oracleTestStore.ExecuteNonQuery(
                @"CREATE OR REPLACE PROCEDURE ""Ten Most Expensive Products""(cur OUT sys_refcursor) AS
BEGIN
  OPEN cur FOR
  SELECT ""ProductName"" AS ""TenMostExpensiveProducts"", ""UnitPrice""
  FROM ""Products""
  ORDER BY ""UnitPrice"" DESC
  FETCH NEXT 10 ROWS ONLY;
END;");

            oracleTestStore.ExecuteNonQuery(
                @"CREATE OR REPLACE PROCEDURE ""CustOrderHist""(CustomerID IN NCHAR, cur OUT sys_refcursor) AS
BEGIN
  OPEN cur FOR
  SELECT ""ProductName"", SUM(""Quantity"") AS ""Total""
  FROM ""Products"" P, ""Order Details"" OD, ""Orders"" O, ""Customers"" C
  WHERE C.""CustomerID"" = CustomerID
  AND C.""CustomerID"" = O.""CustomerID"" AND O.""OrderID"" = OD.""OrderID"" AND OD.""ProductID"" = P.""ProductID""
  GROUP BY ""ProductName"";
END;");
            oracleTestStore.ExecuteNonQuery(
                @"CREATE OR REPLACE PROCEDURE ""SimpleProcedure"" AS
BEGIN
  NULL;
END;");

            oracleTestStore.ExecuteNonQuery(
                @"CREATE OR REPLACE PROCEDURE ""SimpleProcedure2""(""CustomerID"" NCHAR) AS
BEGIN
  NULL;
END;");

            return(oracleTestStore);
        }