public void InsertWithUserType() { var tableName = ObjectName.Parse("APP.test_table"); var columns = new[] { "first_name", "last_name", "active", "user_obj" }; var values = new List <SqlExpression[]> { new SqlExpression[] { SqlExpression.Constant("Antonello"), SqlExpression.Constant("Provenzano"), SqlExpression.Constant(true), SqlExpression.FunctionCall("type1", new SqlExpression[] { SqlExpression.Constant("test1"), SqlExpression.Constant(1), }) }, new SqlExpression[] { SqlExpression.Constant("Mart"), SqlExpression.Constant("Roosmaa"), SqlExpression.Constant(false), SqlExpression.FunctionCall("type1", new SqlExpression[] { SqlExpression.Constant("test2"), SqlExpression.Constant(3), }) } }; var count = AdminQuery.Insert(tableName, columns, values.ToArray()); Assert.AreEqual(2, count); var table = AdminQuery.Access().GetTable(tableName); Assert.IsNotNull(table); Assert.AreEqual(2, table.RowCount); }
public void Callback() { var tableName = ObjectName.Parse("APP.test_table"); AdminQuery.Access().CreateCallbackTrigger("callback1", tableName, TriggerEventTime.After, TriggerEventType.Insert); var reset = new AutoResetEvent(false); TriggerEvent firedEvent = null; AdminQuery.Context.RouteImmediate <TriggerEvent>(e => { firedEvent = e; reset.Set(); }, e => e.TriggerType == TriggerType.Callback && e.TriggerName.Name.Equals("callback1")); AdminQuery.Insert(tableName, new[] { "id", "name" }, new SqlExpression[] { SqlExpression.Constant(2), SqlExpression.Constant("The Name") }); reset.WaitOne(300); Assert.IsNotNull(firedEvent); Assert.AreEqual(TriggerEventTime.After, firedEvent.EventTime); Assert.AreEqual(TriggerEventType.Insert, firedEvent.EventType); }
public void TwoValues_NoColumnes() { var tableName = ObjectName.Parse("APP.test_table"); var values = new List <SqlExpression[]> { new SqlExpression[] { SqlExpression.Constant("Antonello"), SqlExpression.Constant("Provenzano"), SqlExpression.Constant(true) }, new SqlExpression[] { SqlExpression.Constant("Mart"), SqlExpression.Constant("Roosmaa"), SqlExpression.Constant(false) } }; var count = AdminQuery.Insert(tableName, values.ToArray()); Assert.AreEqual(2, count); var table = AdminQuery.Access().GetTable(tableName); Assert.IsNotNull(table); Assert.AreEqual(2, table.RowCount); }
public void CreateExternalFunction() { var funName = ObjectName.Parse("APP.fun1"); var parameters = new RoutineParameter[] { new RoutineParameter("a", PrimitiveTypes.Integer()), new RoutineParameter("b", PrimitiveTypes.Integer()), }; var externRef = ExternalRef.MakeRef(typeof(Test), "Function(int, int)"); AdminQuery.CreateExternFunction(funName, PrimitiveTypes.Integer(), parameters, externRef.ToString()); var exists = AdminQuery.Access().RoutineExists(funName); Assert.IsTrue(exists); var function = AdminQuery.Access().GetObject(DbObjectType.Routine, funName); Assert.IsNotNull(function); Assert.IsInstanceOf <ExternalFunction>(function); var externFunction = (ExternalFunction)function; Assert.IsNotNull(externFunction.ExternalRef); Assert.AreEqual(typeof(Test), externFunction.ExternalRef.Type); }
public void CreateExternalProcedure() { var procName = ObjectName.Parse("APP.proc1"); var parameters = new RoutineParameter[] { new RoutineParameter("a", PrimitiveTypes.Integer()), new RoutineParameter("b", PrimitiveTypes.Integer()), }; var externRef = ExternalRef.MakeRef(typeof(Test), "Procedure(int, int)"); AdminQuery.CreateExternProcedure(procName, parameters, externRef.ToString()); var exists = AdminQuery.Access().RoutineExists(procName); Assert.IsTrue(exists); var procedure = AdminQuery.Access().GetObject(DbObjectType.Routine, procName); Assert.IsNotNull(procedure); Assert.IsInstanceOf <ExternalProcedure>(procedure); var externFunction = (ExternalProcedure)procedure; Assert.IsNotNull(externFunction.ExternalRef); Assert.AreEqual(typeof(Test), externFunction.ExternalRef.Type); }
protected override bool OnTearDown(string testName, IQuery query) { var functionName = ObjectName.Parse("APP.func1"); AdminQuery.Access().DropObject(DbObjectType.Routine, functionName); return(true); }
public void OneValueWithLob() { const string testBio = "A simple test string that can span several characters, " + "that is trying to be the longest possible, just to prove" + "the capacity of a LONG VARCHAR to handle very long strings. " + "Anyway it is virtually impossible to reach the maximum size " + "of a long object, that is organized in 64k byte pages and " + "spans within the local system without any constraint of size. " + "For sake of memory anyway, the maximum size of the test object " + "is set to just 2048 bytes."; var tableName = ObjectName.Parse("APP.test_table"); var columns = new[] { "first_name", "last_name", "active", "bio" }; var bio = CreateBio(testBio); var values = new List <SqlExpression[]> { new[] { SqlExpression.Constant("Antonello"), SqlExpression.Constant("Provenzano"), SqlExpression.Constant(true), SqlExpression.Constant(bio) }, }; var count = AdminQuery.Insert(tableName, columns, values.ToArray()); Assert.AreEqual(1, count); var table = AdminQuery.Access().GetTable(tableName); Assert.IsNotNull(table); Assert.AreEqual(1, table.RowCount); }
protected override void OnAfterSetup(string testName) { AdminQuery.Access().CreateTable(table => table .Named("APP.test_table") .WithColumn("a", PrimitiveTypes.Integer()) .WithColumn("b", PrimitiveTypes.String())); }
public void GrantRoleToUser() { AdminQuery.GrantRole("test_user", "test_role"); var inRole = AdminQuery.Access().UserIsInRole("test_user", "test_role"); Assert.IsTrue(inRole); }
public void SystemRole() { Assert.Throws <SecurityException>(() => AdminQuery.DropRole(SystemRoles.SecureAccessRole)); var exists = AdminQuery.Access().RoleExists(SystemRoles.SecureAccessRole); Assert.IsTrue(exists); }
public void ExistingRole() { AdminQuery.DropRole("test_role"); var exists = AdminQuery.Access().RoleExists("test_role"); Assert.IsFalse(exists); }
public void Lock() { AdminQuery.SetAccountLocked("test_user"); var newStatus = AdminQuery.Access().GetUserStatus("test_user"); Assert.AreEqual(UserStatus.Locked, newStatus); }
public void Existing() { AdminQuery.DropCallbackTrigger(triggerName); var exists = AdminQuery.Access().TriggerExists(new ObjectName(triggerName)); Assert.IsFalse(exists); }
public void NewRole() { AdminQuery.CreateRole("db_admin"); var exists = AdminQuery.Access().RoleExists("db_admin"); Assert.IsTrue(exists); }
public void TypicalClode() { AdminQuery.Close("c1"); var cursor = (Cursor)AdminQuery.Access().FindObject(new ObjectName("c1")); Assert.AreEqual(CursorStatus.Closed, cursor.Status); }
public void RoleFromUser() { AdminQuery.RevokeRole("test_user", "test_role"); var inRole = AdminQuery.Access().UserIsInRole("test_user", "test_role"); Assert.IsFalse(inRole); }
public void Disable() { AdminQuery.DisableTrigger(triggerName); var trigger = (Trigger)AdminQuery.Access().GetObject(DbObjectType.Trigger, triggerName); Assert.AreEqual(TriggerStatus.Disabled, trigger.TriggerInfo.Status); }
public void SetPassword() { AdminQuery.SetPassword("test_user", "1234"); var authenticated = AdminQuery.Access().Authenticate("test_user", "1234"); Assert.IsTrue(authenticated); }
protected override void OnAfterSetup(string testName) { AdminQuery.Access().CreateObject(new VariableInfo("a", PrimitiveTypes.Integer(), false)); AdminQuery.Access().CreateObject(new VariableInfo("b", PrimitiveTypes.Integer(), true) { DefaultExpression = SqlExpression.Constant(56) }); }
public void ExistingTrigger() { AdminQuery.DropTrigger(triggerName); var exists = AdminQuery.Access().TriggerExists(triggerName); Assert.IsFalse(exists); }
public void RenameTo() { var newName = ObjectName.Parse("APP.trigger2"); AdminQuery.RenameTrigger(triggerName, newName); Assert.IsFalse(AdminQuery.Access().TriggerExists(triggerName)); Assert.IsTrue(AdminQuery.Access().TriggerExists(newName)); }
protected override void OnAfterSetup(string testName) { if (testName == "SelectSingleVariable") { AdminQuery.Access().CreateObject(new VariableInfo("a", PrimitiveTypes.Bit(), false)); } base.OnAfterSetup(testName); }
public void ResolveSchemaName() { var resolved = AdminQuery.Access().ResolveObjectName("APP"); Assert.IsNotNull(resolved); Assert.IsNull(resolved.Parent); Assert.IsNotNull(resolved.Name); Assert.AreEqual("APP", resolved.Name); }
public void Simple_UseBuilder() { tableName = ObjectName.Parse("APP.test"); AdminQuery.CreateTable(table => table.Named("APP.test") .WithColumn("id", PrimitiveTypes.Integer()) .WithColumn("name", PrimitiveTypes.String())); Assert.IsTrue(AdminQuery.Access().TableExists(tableName)); }
public void PrivilegeFromUser() { var tableName = ObjectName.Parse("APP.test_table"); AdminQuery.Revoke("test_user", Privileges.Alter, ObjectName.Parse("APP.test_table")); var hasPrivs = AdminQuery.Access().UserHasPrivilege("test_user", DbObjectType.Table, tableName, Privileges.Alter); Assert.IsFalse(hasPrivs); }
public void Existing() { var procName = ObjectName.Parse("APP.proc1"); AdminQuery.DropProcedure(procName); var exists = AdminQuery.Access().ObjectExists(DbObjectType.Routine, procName); Assert.IsFalse(exists); }
public void Simple() { var seqName = ObjectName.Parse("APP.seq2"); AdminQuery.CreateSequence(seqName); var exists = AdminQuery.Access().ObjectExists(DbObjectType.Sequence, seqName); Assert.IsTrue(exists); }
public void Existing() { var seqName = ObjectName.Parse("APP.seq1"); AdminQuery.DropSequence(seqName); var exists = AdminQuery.Access().ObjectExists(DbObjectType.Sequence, seqName); Assert.IsFalse(exists); }
public void IfExists() { var typeName = ObjectName.Parse("APP.type2"); AdminQuery.DropType(typeName, true); var exists = AdminQuery.Access().ObjectExists(DbObjectType.Type, typeName); Assert.IsFalse(exists); }
public void Existing() { var funcName = ObjectName.Parse("APP.func1"); AdminQuery.DropFunction(funcName); var exists = AdminQuery.Access().ObjectExists(DbObjectType.Routine, funcName); Assert.IsFalse(exists); }