瀏覽代碼

modify unit tests.

master
Savorboard 7 年之前
父節點
當前提交
7bcc2e9f1d
共有 5 個文件被更改,包括 7 次插入25 次删除
  1. +0
    -1
      src/DotNetCore.CAP.SqlServer/SqlServerStorage.cs
  2. +6
    -6
      test/DotNetCore.CAP.SqlServer.Test/DatabaseTestHost.cs
  3. +0
    -2
      test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj
  4. +0
    -13
      test/DotNetCore.CAP.SqlServer.Test/TestDbContext.cs
  5. +1
    -3
      test/DotNetCore.CAP.SqlServer.Test/TestHost.cs

+ 0
- 1
src/DotNetCore.CAP.SqlServer/SqlServerStorage.cs 查看文件

@@ -2,7 +2,6 @@ using System.Data.SqlClient;
using System.Threading;
using System.Threading.Tasks;
using Dapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

namespace DotNetCore.CAP.SqlServer


+ 6
- 6
test/DotNetCore.CAP.SqlServer.Test/DatabaseTestHost.cs 查看文件

@@ -1,4 +1,5 @@
using System.Data;
using System.Data.SqlClient;
using System.Threading;
using Dapper;
using Microsoft.EntityFrameworkCore;
@@ -54,21 +55,20 @@ CREATE DATABASE [{databaseName}];");

private void DeleteAllData()
{
using (CreateScope())
var conn = ConnectionUtil.GetConnectionString();
using (var connection = new SqlConnection(conn))
{
var context = GetService<TestDbContext>();

var commands = new[]
{
var commands = new[] {
"DISABLE TRIGGER ALL ON ?",
"ALTER TABLE ? NOCHECK CONSTRAINT ALL",
"DELETE FROM ?",
"ALTER TABLE ? CHECK CONSTRAINT ALL",
"ENABLE TRIGGER ALL ON ?"
};

foreach (var command in commands)
{
context.Database.GetDbConnection().Execute(
connection.Execute(
"sp_MSforeachtable",
new { command1 = command },
commandType: CommandType.StoredProcedure);


+ 0
- 2
test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj 查看文件

@@ -27,8 +27,6 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
</ItemGroup>

</Project>

+ 0
- 13
test/DotNetCore.CAP.SqlServer.Test/TestDbContext.cs 查看文件

@@ -1,13 +0,0 @@
using Microsoft.EntityFrameworkCore;

namespace DotNetCore.CAP.SqlServer.Test
{
public class TestDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var connectionString = ConnectionUtil.GetConnectionString();
optionsBuilder.UseSqlServer(connectionString);
}
}
}

+ 1
- 3
test/DotNetCore.CAP.SqlServer.Test/TestHost.cs 查看文件

@@ -1,5 +1,4 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace DotNetCore.CAP.SqlServer.Test
@@ -30,8 +29,7 @@ namespace DotNetCore.CAP.SqlServer.Test

_connectionString = ConnectionUtil.GetConnectionString();
services.AddSingleton(new SqlServerOptions { ConnectionString = _connectionString });
services.AddSingleton<SqlServerStorage>();
services.AddDbContext<TestDbContext>(options => options.UseSqlServer(_connectionString));
services.AddSingleton<SqlServerStorage>();

_services = services;
}


Loading…
取消
儲存