mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
使用SharedContext模式调整FreeSql.Tests的SqlServer连接。
This commit is contained in:
15
FreeSql.Tests/DataContext/SqlServer/SqlServerCollection.cs
Normal file
15
FreeSql.Tests/DataContext/SqlServer/SqlServerCollection.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.DataContext.SqlServer
|
||||
{
|
||||
[CollectionDefinition("SqlServerCollection")]
|
||||
public class SqlServerCollection : ICollectionFixture<SqlServerFixture>
|
||||
{
|
||||
// This class has no code, and is never created. Its purpose is simply
|
||||
// to be the place to apply [CollectionDefinition] and all the
|
||||
// ICollectionFixture<> interfaces.
|
||||
}
|
||||
}
|
29
FreeSql.Tests/DataContext/SqlServer/SqlServerFixture.cs
Normal file
29
FreeSql.Tests/DataContext/SqlServer/SqlServerFixture.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FreeSql.Tests.DataContext.SqlServer
|
||||
{
|
||||
public class SqlServerFixture : IDisposable
|
||||
{
|
||||
public SqlServerFixture()
|
||||
{
|
||||
sqlServerLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=cms;Pooling=true;Max Pool Size=10")
|
||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=(localdb)\\mssqllocaldb;Integrated Security=True;Initial Catalog=cms;Pooling=true;Max Pool Size=10")
|
||||
.UseAutoSyncStructure(true)
|
||||
.UseLazyLoading(true)
|
||||
.Build());
|
||||
|
||||
// ... initialize data in the test database ...
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// ... clean up test data from the database ...
|
||||
}
|
||||
|
||||
private Lazy<IFreeSql> sqlServerLazy;
|
||||
public IFreeSql SqlServer => sqlServerLazy.Value;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user