Ejemplo n.º 1
0
        private void assertIdentifierLengths(StoreOptions options)
        {
            foreach (var index in _mapping.Indexes)
            {
                options.AssertValidIdentifier(index.IndexName);
            }

            options.AssertValidIdentifier(_mapping.UpsertFunction.Name);
            options.AssertValidIdentifier(_mapping.Table.Name);
        }
Ejemplo n.º 2
0
 public static void AssertValidNames(this ISchemaObject[] schemaObjects, StoreOptions options)
 {
     foreach (var objectName in schemaObjects.SelectMany(x => x.AllNames()))
     {
         options.AssertValidIdentifier(objectName.Name);
     }
 }
Ejemplo n.º 3
0
        public void assert_identifier_null_or_whitespace()
        {
            var options = new StoreOptions();

            Exception <PostgresqlIdentifierInvalidException> .ShouldBeThrownBy(() =>
            {
                options.AssertValidIdentifier(null);
            });

            for (var i = 0; i < options.NameDataLength; i++)
            {
                var text = new string(' ', i);

                Exception <PostgresqlIdentifierInvalidException> .ShouldBeThrownBy(() =>
                {
                    options.AssertValidIdentifier(text);
                });
            }
        }
Ejemplo n.º 4
0
        public void assert_identifier_length_exceeding_maximum()
        {
            var options = new StoreOptions();

            var text = new string('a', options.NameDataLength);

            Exception <PostgresqlIdentifierTooLongException> .ShouldBeThrownBy(() =>
            {
                options.AssertValidIdentifier(text);
            });
        }
Ejemplo n.º 5
0
        public void assert_identifier_length_happy_path()
        {
            var options = new StoreOptions();

            for (var i = 1; i < options.NameDataLength; i++)
            {
                var text = new string('a', i);

                options.AssertValidIdentifier(text);
            }
        }
Ejemplo n.º 6
0
        public void assert_identifier_must_not_contain_space()
        {
            var random  = new Random();
            var options = new StoreOptions();

            for (var i = 1; i < options.NameDataLength; i++)
            {
                var text     = new string('a', i);
                var position = random.Next(0, i);

                Exception <PostgresqlIdentifierInvalidException> .ShouldBeThrownBy(() =>
                {
                    options.AssertValidIdentifier(text.Remove(position).Insert(position, " "));
                });
            }
        }