2019-01-18 01:10:19 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Xunit;
|
2019-01-11 23:20:28 +08:00
|
|
|
|
|
|
|
|
|
namespace Bootstrap.DataAccess
|
|
|
|
|
{
|
2019-01-24 17:58:06 +08:00
|
|
|
|
[Collection("SQLServerContext")]
|
2019-05-11 12:15:03 +08:00
|
|
|
|
public class GroupsTest
|
2019-01-11 23:20:28 +08:00
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Retrieves_Ok()
|
|
|
|
|
{
|
|
|
|
|
Group g = new Group();
|
|
|
|
|
Assert.NotEmpty(g.Retrieves());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2019-01-18 01:10:19 +08:00
|
|
|
|
public void SaveAndDelete_Ok()
|
2019-01-11 23:20:28 +08:00
|
|
|
|
{
|
|
|
|
|
Group g = new Group() { GroupName = "UnitTest", Description = "UnitTestSave" };
|
|
|
|
|
Assert.True(g.Save(g));
|
|
|
|
|
|
2019-01-18 01:10:19 +08:00
|
|
|
|
var ids = g.Retrieves().Where(t => t.GroupName == "UnitTest").Select(t => t.Id);
|
|
|
|
|
Assert.True(g.Delete(ids));
|
2019-01-11 23:20:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void RetrievesByRoleId_Ok()
|
|
|
|
|
{
|
|
|
|
|
Group p = new Group();
|
2019-01-18 01:10:19 +08:00
|
|
|
|
var groups = p.RetrievesByRoleId(new Role().Retrieves().Where(r => r.RoleName == "Administrators").First().Id);
|
|
|
|
|
Assert.NotEmpty(groups);
|
2019-01-11 23:20:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void RetrievesByUserId_Ok()
|
|
|
|
|
{
|
|
|
|
|
Group p = new Group();
|
|
|
|
|
var groups = p.RetrievesByUserId("1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SaveByUserId_Ok()
|
|
|
|
|
{
|
|
|
|
|
Group p = new Group();
|
|
|
|
|
var groups = p.SaveByUserId("1", new string[] { "1", "2", "3" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SaveByRoleId_Ok()
|
|
|
|
|
{
|
|
|
|
|
Group p = new Group();
|
|
|
|
|
var groups = p.SaveByRoleId("1", new string[] { "1", "2" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void RetrievesByUserName_Ok()
|
|
|
|
|
{
|
|
|
|
|
Group p = new Group();
|
2019-05-11 12:15:03 +08:00
|
|
|
|
Assert.NotNull(p.RetrievesByUserName("Admin"));
|
2019-01-11 23:20:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|