コード例 #1
0
        public void Block_size_is_obtained_from_named_sequence()
        {
            var property = CreateConventionModelBuilder()
                .Entity<Robot>()
                .Property(e => e.Id)
                .ForSqlServerUseSequenceHiLo("DaneelOlivaw")
                .Metadata;

            var cache = new SqlServerValueGeneratorCache();

            Assert.Equal(10, cache.GetOrAddSequenceState(property).Sequence.IncrementBy);
        }
コード例 #2
0
        public void Sequence_name_is_obtained_from_model_default_sequence()
        {
            var property = CreateConventionModelBuilder()
                .ForSqlServerUseSequenceHiLo()
                .Entity<Robot>()
                .Property(e => e.Id)
                .Metadata;

            var cache = new SqlServerValueGeneratorCache();

            Assert.Equal("EntityFrameworkHiLoSequence", cache.GetOrAddSequenceState(property).Sequence.Name);
        }
コード例 #3
0
        public void Schema_qualified_sequence_name_is_obtained_from_specified_model_default_sequence()
        {
            var property = CreateConventionModelBuilder()
                .ForSqlServerUseSequenceHiLo("DaneelOlivaw", "R")
                .ForSqlServerHasSequence("DaneelOlivaw", "R", b => b.IncrementsBy(11))
                .Entity<Robot>()
                .Property(e => e.Id)
                .Metadata;

            var cache = new SqlServerValueGeneratorCache();

            Assert.Equal("DaneelOlivaw", cache.GetOrAddSequenceState(property).Sequence.Name);
            Assert.Equal("R", cache.GetOrAddSequenceState(property).Sequence.Schema);
        }
コード例 #4
0
        public void Non_positive_block_sizes_are_not_allowed()
        {
            var property = CreateConventionModelBuilder()
                .ForSqlServerHasSequence("DaneelOlivaw", b => b.IncrementsBy(-1))
                .Entity<Robot>()
                .Property(e => e.Id)
                .ForSqlServerUseSequenceHiLo("DaneelOlivaw")
                .Metadata;

            var cache = new SqlServerValueGeneratorCache();

            Assert.StartsWith(
                CoreStrings.HiLoBadBlockSize,
                Assert.Throws<ArgumentOutOfRangeException>(() => cache.GetOrAddSequenceState(property).Sequence.IncrementBy).Message);
        }