44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using e_suite.API.Common;
|
|
using e_suite.UnitTestCore;
|
|
using eSuite.API.Controllers;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Moq;
|
|
using System.Security.Claims;
|
|
|
|
namespace eSuite.API.UnitTests.Controllers.ExceptionLogsControllerUnitTest;
|
|
|
|
public class ExceptionLogsControllerTestBase : TestBase
|
|
{
|
|
protected Mock<IExceptionLogManager> _exceptionLogManagerMock = null!;
|
|
protected ExceptionLogsController _exceptionLogsController = null!;
|
|
|
|
public override async Task Setup()
|
|
{
|
|
await base.Setup();
|
|
_exceptionLogManagerMock = new Mock<IExceptionLogManager>();
|
|
_exceptionLogsController = new ExceptionLogsController(_exceptionLogManagerMock.Object);
|
|
|
|
const long id = -1;
|
|
const string email = "email@mail.test";
|
|
const string displayName = "Test User";
|
|
|
|
AddAuthorisedUserToController(id, email, displayName);
|
|
}
|
|
|
|
protected void AddAuthorisedUserToController(long id, string email, string displayName)
|
|
{
|
|
var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
|
|
{
|
|
new(ClaimTypes.PrimarySid, id.ToString()),
|
|
new(ClaimTypes.Email, email),
|
|
new(ClaimTypes.Name, displayName)
|
|
}, "TestAuthentication"));
|
|
|
|
_exceptionLogsController.ControllerContext = new ControllerContext
|
|
{
|
|
HttpContext = new DefaultHttpContext { User = user }
|
|
};
|
|
}
|
|
}
|