53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using e_suite.Modules.RoleManager.UnitTests.Helpers;
|
|
using e_suite.Utilities.Pagination;
|
|
using eSuite.Core.Security;
|
|
using NUnit.Framework;
|
|
using System.Reflection;
|
|
|
|
namespace e_suite.Modules.RoleManager.UnitTests;
|
|
|
|
[TestFixture]
|
|
public class GetAccessListUnitTests : RoleManagerTestBase
|
|
{
|
|
[SetUp]
|
|
public override async Task Setup()
|
|
{
|
|
await base.Setup();
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetAccessList_WhenCalledWithPageZero_ReturnsCompleteAccessList()
|
|
{
|
|
//Arrange
|
|
var expectedResult = Enum.GetValues<SecurityAccess>()
|
|
.Where(t => typeof(SecurityAccess).GetField(t.ToString())?.GetCustomAttribute<ObsoleteAttribute>() == null &&
|
|
typeof(SecurityAccess).GetField(t.ToString())?.GetCustomAttribute<HiddenAttribute>() == null)
|
|
.ToList();
|
|
expectedResult.Remove(SecurityAccess.Everyone); //This is not returned to the client, everyone gets this for free and it cannot be turned off.
|
|
|
|
var paging = new Paging
|
|
{
|
|
Page = 0
|
|
};
|
|
|
|
//Act
|
|
var actualResult = await RoleManager.GetAccessList(paging, CancellationToken.None);
|
|
|
|
//Assert
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(actualResult, Is.Not.Null);
|
|
Assert.That(actualResult.Count, Is.EqualTo(expectedResult.Count));
|
|
Assert.That(actualResult.Data.Count(), Is.EqualTo(expectedResult.Count));
|
|
|
|
foreach (var item in actualResult.Data)
|
|
{
|
|
Assert.That(item.Name.Trim().Length, Is.GreaterThan(1));
|
|
Assert.That(item.Description.Trim().Length, Is.GreaterThan(1));
|
|
Assert.That(item.GroupName.Trim().Length, Is.GreaterThan(1));
|
|
Assert.That(item.SecurityAccess, Is.Not.Null);
|
|
}
|
|
Assert.That(actualResult.Data, Is.Unique);
|
|
});
|
|
}
|
|
} |