예제 #1
0
        public void QueryClass_SqlValidate_Succeeds(Type queryClassType)
        {
            object[] parameters = HelperQueryCommandClasses.CreateDummyParametersForType(queryClassType);
            var      instance   = (IQueryValidator)Activator.CreateInstance(queryClassType, parameters);

            instance.Validate(this.TestFixture.SqlSession);
        }
예제 #2
0
        public void CommandClass_SqlValidate_Succeeds(Type commandClassType)
        {
            object[] parameters = HelperQueryCommandClasses.CreateDummyParametersForType(commandClassType, TestObjectFactory.Instance);
            var      instance   = (ICommandValidator)Activator.CreateInstance(commandClassType, parameters);

            instance.Validate(this.TestFixture.SqlSession);

            // Make sure UPDATE and DELETE statements are containing WHERE clause to avoid all-update or all-delete situations.
            if ((instance.SqlStatement.StartsWith(
                     "UPDATE",
                     StringComparison.InvariantCultureIgnoreCase) ||
                 instance.SqlStatement.StartsWith("DELETE", StringComparison.InvariantCultureIgnoreCase)) &&
                !instance.SqlStatement.Contains("WHERE", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new DatabaseStatementSyntaxException("UPDATE or DELETE statement without WHERE clause.", instance.SqlStatement);
            }
        }