单元测试:增加App类单元测试
This commit is contained in:
parent
473641b155
commit
45d2394f15
|
@ -0,0 +1,40 @@
|
|||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
[Collection("SQLServerContext")]
|
||||
public class AppTest
|
||||
{
|
||||
[Fact]
|
||||
public void RetrievesByRoleId_Ok()
|
||||
{
|
||||
var db = DbManager.Create();
|
||||
db.Execute("delete from RoleApp");
|
||||
var rid = new Role().Retrieves().Where(r => r.RoleName == "Administrators").First().Id;
|
||||
var app = new App();
|
||||
Assert.NotEmpty(app.RetrievesByRoleId(rid));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RetrievesByUserName_Ok()
|
||||
{
|
||||
var app = new App();
|
||||
Assert.NotEmpty(app.RetrievesByUserName("Admin"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SaveByRoleId_Ok()
|
||||
{
|
||||
var db = DbManager.Create();
|
||||
db.Execute("delete from RoleApp");
|
||||
|
||||
var rid = new Role().Retrieves().Where(r => r.RoleName == "Administrators").First().Id;
|
||||
var app = new App();
|
||||
Assert.True(app.SaveByRoleId(rid, new string[] { "1", "2" }));
|
||||
|
||||
var count = db.ExecuteScalar<int>("select count(Id) from RoleApp where RoleID = @0", rid);
|
||||
Assert.Equal(2, count);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using Xunit;
|
||||
|
||||
namespace Bootstrap.DataAccess.MySql
|
||||
{
|
||||
[Collection("MySqlContext")]
|
||||
public class AppTest : DataAccess.AppTest
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using Xunit;
|
||||
|
||||
namespace Bootstrap.DataAccess.SQLite
|
||||
{
|
||||
[Collection("SQLiteContext")]
|
||||
public class AppTest : DataAccess.AppTest
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue