Esempio n. 1
0
        public override bool Check(string query)
        {
            var arguments = InsertUtils.GetArgumentsFromQuery(query);
            var tableName = InsertUtils.GetTableNameFromQuery(query);

            var columns = InsertUtils.GetColumnsFromArguments(arguments).ToArray();
            var values  = arguments[2].Split(",").Select(x => x.Trim()).ToArray();

            var columnProperties = _database.GetTable(tableName).GetColumnProperties();

            for (var i = 0; i < columns.Count(); i++)
            {
                if (GeneralUtils.ContainsForbiddenCharacters(values[i]))
                {
                    throw new ForbiddenCharactersException(values[i]);
                }

                var type = columnProperties.First(x => x.Name == columns[i]).Type;
                if (!GeneralUtils.IsTypeValid(type, values[i]))
                {
                    throw new InvalidColumnTypeException(columns[i], type);
                }
            }

            return(this.CheckNext(query));
        }
Esempio n. 2
0
        public void ContainsForbiddenCharacters_StringContainsForbiddenCharacters_ShouldReturnTrue(string input)
        {
            var actual = GeneralUtils.ContainsForbiddenCharacters(input);

            Assert.True(actual);
        }