Beispiel #1
0
        public void UseMySql_without_connection_string()
        {
            var builder       = new DbContextOptionsBuilder();
            var serverVersion = ServerVersion.AutoDetect(AppConfig.ConnectionString);

            builder.UseMySql(serverVersion);

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);
        }
        private static MySqlOptions GetOptions(Action <MySqlDbContextOptionsBuilder> builder)
        {
            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(
                new DbContextOptionsBuilder()
                .UseMySql("Server=foo", builder)
                .Options);

            return(mySqlOptions);
        }
        public void TreatTinyAsBoolean_unspecified()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql("Server=foo", AppConfig.ServerVersion);

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(MySqlBooleanType.Default, mySqlOptions.DefaultDataTypeMappings.ClrBoolean);
        }
Beispiel #4
0
        public void TreatTinyAsBoolean_false()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql("TreatTinyAsBoolean=False");

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(MySqlBooleanType.Bit1, mySqlOptions.DefaultDataTypeMappings.ClrBoolean);
        }
Beispiel #5
0
        public void Explicit_DefaultDataTypeMappings_take_precedence_over_TreatTinyAsBoolean_false()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql(
                "TreatTinyAsBoolean=False",
                b => b.DefaultDataTypeMappings(m => m.WithClrBoolean(MySqlBooleanType.TinyInt1)));

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(MySqlBooleanType.TinyInt1, mySqlOptions.DefaultDataTypeMappings.ClrBoolean);
        }
Beispiel #6
0
        public void UseMySql_without_connection_explicit_DefaultDataTypeMappings_is_applied()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql(
                AppConfig.ServerVersion,
                b => b.DefaultDataTypeMappings(m => m.WithClrBoolean(MySqlBooleanType.Bit1)));

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(MySqlBooleanType.Bit1, mySqlOptions.DefaultDataTypeMappings.ClrBoolean);
        }
        public void UseMySql_with_MariaDbServerVersion_LatestSupportedServerVersion()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql(
                "Server=foo",
                MariaDbServerVersion.LatestSupportedServerVersion);

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(MariaDbServerVersion.LatestSupportedServerVersion.Version, mySqlOptions.ServerVersion.Version);
            Assert.Equal(ServerType.MariaDb, mySqlOptions.ServerVersion.Type);
            Assert.Equal("mariadb", mySqlOptions.ServerVersion.TypeIdentifier);
        }
        public void UseMySql_with_MariaDbServerVersion_ServerVersion()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql(
                "Server=foo",
                new MariaDbServerVersion(new MariaDbServerVersion(new Version(10, 5, 5))));

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(new Version(10, 5, 5), mySqlOptions.ServerVersion.Version);
            Assert.Equal(ServerType.MariaDb, mySqlOptions.ServerVersion.Type);
            Assert.Equal("mariadb", mySqlOptions.ServerVersion.TypeIdentifier);
        }
        public void UseMySql_with_MySqlServerVersion_ServerVersion()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql(
                "Server=foo",
                new MySqlServerVersion(new MySqlServerVersion(new Version(8, 0, 21))));

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(new Version(8, 0, 21), mySqlOptions.ServerVersion.Version);
            Assert.Equal(ServerType.MySql, mySqlOptions.ServerVersion.Type);
            Assert.Equal("mysql", mySqlOptions.ServerVersion.TypeIdentifier);
        }
        public void UseMySql_with_ServerVersion_AutoDetect()
        {
            var builder       = new DbContextOptionsBuilder();
            var serverVersion = ServerVersion.AutoDetect(AppConfig.ConnectionString);

            builder.UseMySql(
                "Server=foo",
                serverVersion);

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(serverVersion.Version, mySqlOptions.ServerVersion.Version);
            Assert.Equal(serverVersion.Type, mySqlOptions.ServerVersion.Type);
            Assert.Equal(serverVersion.TypeIdentifier, mySqlOptions.ServerVersion.TypeIdentifier);
        }
Beispiel #11
0
        public void UseMySql_with_ServerVersion_FromString()
        {
            var builder       = new DbContextOptionsBuilder();
            var serverVersion = ServerVersion.Parse("8.0.21-mysql");

            builder.UseMySql(
                "Server=foo",
                serverVersion);

            var mySqlOptions = new MySqlOptions();

            mySqlOptions.Initialize(builder.Options);

            Assert.Equal(new Version(8, 0, 21), mySqlOptions.ServerVersion.Version);
            Assert.Equal(ServerType.MySql, mySqlOptions.ServerVersion.Type);
            Assert.Equal("mysql", mySqlOptions.ServerVersion.TypeIdentifier);
        }