private static async Task Returns_false_when_database_exists_but_has_no_tables_test(bool async) { using (var testDatabase = OracleTestStore.GetOrCreateInitialized("Empty")) { var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(testDatabase); Assert.False(async ? await creator.HasTablesAsyncBase() : creator.HasTablesBase()); } }
private static async Task Creates_schema_in_existing_database_test(bool async) { using (var testDatabase = OracleTestStore.GetOrCreateInitialized("ExistingBlogging" + (async ? "Async" : ""))) { using (var context = new OracleDatabaseCreatorTest.BloggingContext(testDatabase)) { var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(context); if (async) { await creator.CreateTablesAsync(); } else { creator.CreateTables(); } if (testDatabase.ConnectionState != ConnectionState.Open) { await testDatabase.OpenConnectionAsync(); } var tables = (await testDatabase.QueryAsync <string>( "SELECT table_name FROM user_tables")).ToList(); Assert.Equal(1, tables.Count); Assert.Equal("Blogs", tables.Single()); var columns = (await testDatabase.QueryAsync <string>( "SELECT table_name || '.' || column_name || ' (' || data_type || ')' " + "FROM user_tab_columns WHERE table_name = 'Blogs' " + "ORDER BY table_name, column_name")).ToArray(); Assert.Equal(14, columns.Length); Assert.Equal( new[] { "Blogs.AndChew (BLOB)", "Blogs.AndRow (RAW)", "Blogs.Cheese (NVARCHAR2)", "Blogs.ErMilan (NUMBER)", "Blogs.Fuse (NUMBER)", "Blogs.George (NUMBER)", "Blogs.Key1 (NVARCHAR2)", "Blogs.Key2 (RAW)", "Blogs.NotFigTime (TIMESTAMP(6))", "Blogs.On (FLOAT)", "Blogs.OrNothing (FLOAT)", "Blogs.TheGu (RAW)", "Blogs.ToEat (NUMBER)", "Blogs.WayRound (NUMBER)" }, columns); } } }
private static async Task Returns_true_when_database_exists_test(bool async) { using (var testDatabase = OracleTestStore.GetOrCreateInitialized("ExistingBlogging")) { using (var context = new OracleDatabaseCreatorTest.BloggingContext(testDatabase)) { var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(context); Assert.True(async ? await creator.ExistsAsync() : creator.Exists()); Assert.Equal(ConnectionState.Closed, context.Database.GetDbConnection().State); } } }
private static async Task Throws_if_database_already_exists_test(bool async) { using (var testDatabase = OracleTestStore.GetOrCreateInitialized("ExistingBlogging")) { var creator = OracleDatabaseCreatorTest.GetDatabaseCreator(testDatabase); var ex = async ? await Assert.ThrowsAsync <OracleException>(() => creator.CreateAsync()) : Assert.Throws <OracleException>(() => creator.Create()); Assert.Equal( 1920, // Database with given name already exists ex.Number); } }
public override TestStore GetOrCreate(string storeName) { var oracleTestStore = OracleTestStore.GetOrCreateInitialized(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); }