test(MongoDB): 增加单元测试

This commit is contained in:
Argo Zhang 2019-05-13 12:11:15 +08:00
parent 2b7fe380ba
commit 6c57170e96
13 changed files with 137 additions and 3 deletions

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Hosting;
using Longbow.Data;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.Mvc.Testing.Handlers;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using UnitTest;
@ -28,13 +30,19 @@ namespace Bootstrap.Admin
}
[CollectionDefinition("MongoContext")]
public class MongoContext : ICollectionFixture<MongoBAWebHost>
{
}
public class MySqlBAWebHost : BAWebHost
{
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
base.ConfigureWebHost(builder);
TestHelper.ConfigureWebHost(builder, Longbow.Data.DatabaseProviderType.MySql);
TestHelper.ConfigureWebHost(builder, DatabaseProviderType.MySql);
}
}
@ -44,7 +52,22 @@ namespace Bootstrap.Admin
{
base.ConfigureWebHost(builder);
TestHelper.ConfigureWebHost(builder, Longbow.Data.DatabaseProviderType.SQLite);
TestHelper.ConfigureWebHost(builder, DatabaseProviderType.SQLite);
}
}
public class MongoBAWebHost : BAWebHost
{
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
base.ConfigureWebHost(builder);
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
new KeyValuePair<string, string>("DB:1:Enabled", "false"),
new KeyValuePair<string, string>("DB:2:Enabled", "false"),
new KeyValuePair<string, string>("DB:3:Enabled", "false")
}));
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class AppTest : DataAccess.AppTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class DictsTest : DataAccess.DictsTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class ExceptionsTest : DataAccess.ExceptionsTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class GroupsTest : DataAccess.GroupsTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class LogsTest : DataAccess.LogsTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class MenusTest : DataAccess.MenusTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class MessagesTest : DataAccess.MessagesTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class RolesTest : DataAccess.RolesTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class TasksTest : DataAccess.TasksTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class TracesTest : DataAccess.TracesTest
{
}
}

View File

@ -0,0 +1,10 @@
using Xunit;
namespace Bootstrap.DataAccess.MongoDB
{
[Collection("MongoContext")]
public class UsersTest : DataAccess.UsersTest
{
}
}

View File

@ -22,6 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\Bootstrap.Admin\Bootstrap.Admin.csproj" />
<ProjectReference Include="..\Bootstrap.DataAccess.MongoDB\Bootstrap.DataAccess.MongoDB.csproj" />
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj" />
</ItemGroup>