|
1 | 1 | using Microsoft.EntityFrameworkCore; |
2 | | -using Microsoft.EntityFrameworkCore.Infrastructure; |
3 | | -using Pomelo.EntityFrameworkCore.MySql.Infrastructure; |
4 | 2 |
|
5 | 3 | namespace CosmoSQLClient.MySql.Tests; |
6 | 4 |
|
7 | 5 | public class EntityFrameworkCoreTests |
8 | 6 | { |
9 | | - private static readonly ServerVersion ServerVersion = new MySqlServerVersion(new Version(8, 0, 0)); |
10 | | - |
11 | 7 | [Fact] |
12 | 8 | public void UseCosmoMySql_WithConnectionString_ShouldConfigureMySqlConnection() |
13 | 9 | { |
14 | 10 | var options = new DbContextOptionsBuilder<TestDbContext>() |
15 | | - .UseCosmoMySql("Host=localhost;Database=sampledb;User Id=root;Password=password;", ServerVersion) |
| 11 | + .UseCosmoMySql("Host=localhost;Database=sampledb;User Id=root;Password=password;", |
| 12 | + ServerVersion.AutoDetect("")) |
16 | 13 | .Options; |
17 | 14 |
|
18 | 15 | using var context = new TestDbContext(options); |
19 | 16 | Assert.IsType<MySqlConnection>(context.Database.GetDbConnection()); |
20 | 17 | } |
21 | 18 |
|
22 | 19 | [Fact] |
23 | | - public void UseCosmoMySql_WithExistingConnection_ShouldReuseConnection() |
| 20 | + public void UseMySql_WithConnectionString_ShouldConfigureMySqlConnection() |
24 | 21 | { |
25 | | - using var connection = new MySqlConnection("Host=localhost;Database=sampledb;User Id=root;Password=password;"); |
26 | | - |
27 | 22 | var options = new DbContextOptionsBuilder<TestDbContext>() |
28 | | - .UseCosmoMySql(connection, ServerVersion) |
| 23 | + .UseMySql("Host=localhost;Database=sampledb;User Id=root;Password=password;") |
29 | 24 | .Options; |
30 | 25 |
|
31 | 26 | using var context = new TestDbContext(options); |
32 | | - Assert.Same(connection, context.Database.GetDbConnection()); |
| 27 | + Assert.IsType<MySqlConnection>(context.Database.GetDbConnection()); |
33 | 28 | } |
34 | 29 |
|
35 | 30 | private sealed class TestDbContext(DbContextOptions<TestDbContext> options) : DbContext(options) |
|
0 commit comments