public void Throws_setting_sequence_generation_for_invalid_type()
        {
            var modelBuilder = GetModelBuilder();

            var property = modelBuilder
                           .Entity <Customer>()
                           .Property(e => e.Name)
                           .Metadata;

            Assert.Equal(
                MySqlStrings.SequenceBadType("Name", nameof(Customer), "string"),
                Assert.Throws <ArgumentException>(
                    () => property.SetValueGenerationStrategy(MySqlValueGenerationStrategy.SequenceHiLo)).Message);
        }
        public void Throws_setting_sequence_generation_for_invalid_type_only_with_explicit()
        {
            var propertyBuilder = CreateBuilder()
                                  .Entity(typeof(Splot), ConfigurationSource.Convention)
                                  .Property("Name", typeof(string), ConfigurationSource.Convention);

            Assert.False(
                propertyBuilder.MySql(ConfigurationSource.Convention)
                .ValueGenerationStrategy(MySqlValueGenerationStrategy.SequenceHiLo));

            Assert.Equal(
                MySqlStrings.SequenceBadType("Name", nameof(Splot), "string"),
                Assert.Throws <ArgumentException>(
                    () => propertyBuilder.MySql(ConfigurationSource.Explicit).ValueGenerationStrategy(MySqlValueGenerationStrategy.SequenceHiLo)).Message);
        }
Пример #3
0
        public void Throws_setting_sequence_generation_for_invalid_type()
        {
            var propertyBuilder = CreateBuilder()
                                  .Entity(typeof(Splot))
                                  .Property(typeof(string), "Name");

            Assert.Equal(
                MySqlStrings.SequenceBadType("Name", nameof(Splot), "string"),
                Assert.Throws <ArgumentException>(
                    () => propertyBuilder.HasValueGenerationStrategy(MySqlValueGenerationStrategy.SequenceHiLo)).Message);

            Assert.Equal(
                MySqlStrings.SequenceBadType("Name", nameof(Splot), "string"),
                Assert.Throws <ArgumentException>(
                    () => new PropertyBuilder((IMutableProperty)propertyBuilder.Metadata).UseHiLo()).Message);
        }