Started creating tests for database module

This commit is contained in:
2024-11-24 12:40:51 +01:00
parent 1897428d00
commit 85031de3c2
9 changed files with 487 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
namespace HopFrame.Database.Tests;
public class PermissionValidatorTests {
[Fact]
public void IncludesPermission_Returns_True_For_ExactPermission() {
// Arrange
var permissions = new [] { "test.permission", "test.permission.exact" };
var permission = "test.permission.exact";
// Act
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
// Assert
Assert.True(hasPermission);
}
[Fact]
public void IncludesPermission_Returns_True_For_GroupPermission() {
// Arrange
var permissions = new [] { "test.permission.*", "test.permission.exact" };
var permission = "test.permission.exact.other";
// Act
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
// Assert
Assert.True(hasPermission);
}
[Fact]
public void IncludesPermission_Returns_True_For_StarPermission() {
// Arrange
var permissions = new [] { "test.permission", "test.permission.exact", "*" };
var permission = "test.permission.exact.other";
// Act
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
// Assert
Assert.True(hasPermission);
}
[Fact]
public void IncludesPermission_Returns_False() {
// Arrange
var permissions = new [] { "test.permission", "test.permission.exact" };
var permission = "test.permission.exact.other";
// Act
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
// Assert
Assert.False(hasPermission);
}
}