forked from PhenX/PhenX.EntityFrameworkCore.BulkInsert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDbContainerMySql.cs
More file actions
58 lines (42 loc) · 1.82 KB
/
TestDbContainerMySql.cs
File metadata and controls
58 lines (42 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Data.Common;
using Microsoft.EntityFrameworkCore;
using MySqlConnector;
using PhenX.EntityFrameworkCore.BulkInsert.MySql;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
using Testcontainers.MySql;
using Xunit;
using Xunit.Abstractions;
namespace PhenX.EntityFrameworkCore.BulkInsert.Tests.DbContainer;
[CollectionDefinition(Name)]
public class TestDbContainerMySqlCollection : ICollectionFixture<TestDbContainerMySql>
{
public const string Name = "MySql";
}
public class TestDbContainerMySql(IMessageSink messageSink) : TestDbContainer<MySqlBuilder, MySqlContainer>(messageSink)
{
private static readonly ServerVersion MySqlServerVersion = ServerVersion.Create(new Version(8, 0), ServerType.MySql);
public override DbProviderFactory DbProviderFactory => MySqlConnectorFactory.Instance;
protected override MySqlBuilder CreateBuilder() => new($"{MySqlServerVersion.TypeIdentifier}:{MySqlServerVersion.Version}");
protected override string DbmsName => MySqlServerVersion.Type.ToString();
protected override MySqlBuilder Configure()
{
return base.Configure()
.WithCommand("--log-bin-trust-function-creators=1", "--local-infile=1", "--innodb-print-all-deadlocks=ON")
.WithUsername("root")
.WithPassword("root");
}
protected override string GetConnectionString(string databaseName)
{
return $"{base.GetConnectionString(databaseName)};AllowLoadLocalInfile=true;";
}
protected override void Configure(DbContextOptionsBuilder optionsBuilder, string databaseName)
{
var connectionString = GetConnectionString(databaseName);
optionsBuilder
.UseMySql(connectionString, MySqlServerVersion, o =>
{
o.UseNetTopologySuite();
})
.UseBulkInsertMySql();
}
}