public void GrantDatabasePrivilege_DatabaseDoenstExist_NoticeInValidate()
        {
            IDatabaseContainer databaseContainer  = ObjectConstructor.CreateDatabaseContainer();
            string             randomDatabaseName = VariousFunctions.GenerateRandomString(8);

            while (databaseContainer.ExistDatabase(randomDatabaseName))
            {
                randomDatabaseName = VariousFunctions.GenerateRandomString(8);
            }
            GrantDatabasePrivilege grantDatabasePrivilege = CreateGrantDatabasePrivilege(databaseContainer, SystemeConstants.SystemDatabaseName, SystemeConstants.PrivilegesOfProfilesOnDatabasesTableName);

            grantDatabasePrivilege.SetData(SystemeConstants.CreatePrivilegeName, SystemeConstants.DefaultProfile, randomDatabaseName);
            Assert.IsFalse(grantDatabasePrivilege.ValidateParameters());
        }
        public void GrandDatabasePrivilege_PKViolated_NoticeInValidate()
        {
            IDatabaseContainer databaseContainer = ObjectConstructor.CreateDatabaseContainer();
            ITable             table             = databaseContainer.GetDatabase(SystemeConstants.SystemDatabaseName).GetTable(SystemeConstants.PrivilegesOfProfilesOnDatabasesTableName);
            Row row = table.CreateRowDefinition();

            row.GetCell(SystemeConstants.PrivilegesOfProfilesOnDatabasesProfileColumnName).data      = SystemeConstants.DefaultProfile;
            row.GetCell(SystemeConstants.PrivilegesOfProfilesOnDatabasesDatabaseNameColumnName).data = SystemeConstants.DefaultDatabaseName;
            row.GetCell(SystemeConstants.PrivilegesOfProfilesOnDatabasesPrivilegeColumnName).data    = SystemeConstants.CreatePrivilegeName;
            table.AddRow(row);
            GrantDatabasePrivilege grantDatabasePrivilege = CreateGrantDatabasePrivilege(databaseContainer, SystemeConstants.SystemDatabaseName, table.tableName);

            grantDatabasePrivilege.SetData(row.GetCell(SystemeConstants.PrivilegesOfProfilesOnDatabasesPrivilegeColumnName).data, row.GetCell(SystemeConstants.PrivilegesOfProfilesOnDatabasesProfileColumnName).data, row.GetCell(SystemeConstants.PrivilegesOfProfilesOnDatabasesDatabaseNameColumnName).data);
            Assert.IsFalse(grantDatabasePrivilege.ValidateParameters());
        }
        public void GrantDatabasePrivilege_AllParametersAreGood_GrantDatabasePrivilege()
        {
            IDatabaseContainer     databaseContainer      = ObjectConstructor.CreateDatabaseContainer();
            GrantDatabasePrivilege grantDatabasePrivilege = CreateGrantDatabasePrivilege(databaseContainer, SystemeConstants.SystemDatabaseName, SystemeConstants.PrivilegesOfProfilesOnDatabasesTableName);

            grantDatabasePrivilege.SetData(SystemeConstants.CreatePrivilegeName, SystemeConstants.DefaultProfile, SystemeConstants.DefaultDatabaseName);
            Assert.IsTrue(grantDatabasePrivilege.ValidateParameters());
            grantDatabasePrivilege.Execute();
            Select select = TestSelect.CreateSelect(databaseContainer, SystemeConstants.SystemDatabaseName, SystemeConstants.PrivilegesOfProfilesOnDatabasesTableName, true);

            select.whereClause.AddCritery(SystemeConstants.PrivilegesOfProfilesOnDatabasesProfileColumnName, SystemeConstants.DefaultProfile, Operator.equal);
            select.whereClause.AddCritery(SystemeConstants.PrivilegesOfProfilesOnDatabasesDatabaseNameColumnName, SystemeConstants.DefaultDatabaseName, Operator.equal);
            select.whereClause.AddCritery(SystemeConstants.PrivilegesOfProfilesOnDatabasesPrivilegeColumnName, SystemeConstants.CreatePrivilegeName, Operator.equal);
            select.ValidateParameters();
            select.Execute();
            Assert.AreEqual(1, select.GetAfectedRowCount());
        }