public void Default_block_size_is_used_if_not_set_anywhere()
        {
            var property = CreateProperty();

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor());

            Assert.Equal(SqlServerSequenceValueGeneratorFactory.DefaultBlockSize, factory.GetBlockSize(property));
        }
        public void Default_block_size_is_used_if_not_set_anywhere()
        {
            var property = CreateProperty();

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor());

            Assert.Equal(SqlServerSequenceValueGeneratorFactory.DefaultBlockSize, factory.GetBlockSize(property));
        }
        public void Block_size_is_obtained_from_model_annotation_if_not_set_on_property_or_type()
        {
            var property = CreateProperty();
            property.EntityType.Model["StoreSequenceBlockSize"] = "11";

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor());

            Assert.Equal(11, factory.GetBlockSize(property));
        }
        public void Block_size_is_obtained_from_model_annotation_if_not_set_on_property_or_type()
        {
            var property = CreateProperty();

            property.EntityType.Model["StoreSequenceBlockSize"] = "11";

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor());

            Assert.Equal(11, factory.GetBlockSize(property));
        }
        public void Block_size_is_obtained_from_named_sequence()
        {
            var property = new ModelBuilder()
                           .Entity <Robot>()
                           .Property(e => e.Id)
                           .ForSqlServer(b => b.UseSequence("DaneelOlivaw"))
                           .Metadata;

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor(new LoggerFactory()));

            Assert.Equal(10, factory.GetBlockSize(property));
        }
        public void Block_size_is_obtained_from_specified_default_sequence()
        {
            var property = new ModelBuilder()
                           .ForSqlServer(b => b.Sequence().IncrementBy(11))
                           .Entity <Robot>()
                           .Property(e => e.Id)
                           .ForSqlServer(b => b.UseSequence())
                           .Metadata;

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor(new LoggerFactory()));

            Assert.Equal(11, factory.GetBlockSize(property));
        }
Exemplo n.º 7
0
        public void Block_size_is_obtained_from_model_default_sequence()
        {
            var property = CreateConventionModelBuilder()
                           .ForSqlServer(b => b.UseSequence())
                           .Entity <Robot>()
                           .Property(e => e.Id)
                           .GenerateValueOnAdd()
                           .Metadata;

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor(new LoggerFactory()));

            Assert.Equal(10, factory.GetBlockSize(property));
        }
        public void Non_positive_block_sizes_are_not_allowed()
        {
            var property = new ModelBuilder()
                           .ForSqlServer(b => b.Sequence("DaneelOlivaw").IncrementBy(-1))
                           .Entity <Robot>()
                           .Property(e => e.Id)
                           .ForSqlServer(b => b.UseSequence("DaneelOlivaw"))
                           .Metadata;

            var factory = new SqlServerSequenceValueGeneratorFactory(new SqlStatementExecutor(new LoggerFactory()));

            Assert.Equal(
                Strings.SequenceBadBlockSize(-1, "DaneelOlivaw"),
                Assert.Throws <NotSupportedException>(() => factory.GetBlockSize(property)).Message);
        }