refactor: Projektdateien migriert. Cloud-NuGet-Pakete durch lokale NuGet-Projekte ersetzt.
This commit is contained in:
730
XUnitDAL.Test/Test_Controller_Entity.cs
Normal file
730
XUnitDAL.Test/Test_Controller_Entity.cs
Normal file
@@ -0,0 +1,730 @@
|
||||
using DAL.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using NLog.Filters;
|
||||
using StaffDBServer.Controllers;
|
||||
using Xunit;
|
||||
using XUnitWebApi.SharedConfig;
|
||||
|
||||
namespace XUnitWebApi.Controller
|
||||
{
|
||||
public class Test_Controller_Entity
|
||||
{
|
||||
//----Check_GetEntityController
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetSubsidiaryController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
SubsidiaryRepository repository = new SubsidiaryRepository();
|
||||
SubsidiaryController controller = new SubsidiaryController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.SubsidiaryId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamInputFolderController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 49;
|
||||
WindreamInputFolderRepository repository = new WindreamInputFolderRepository();
|
||||
WindreamInputFolderController controller = new WindreamInputFolderController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamInputFolderId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchToDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WindreamSearchToDepartmentRepository repository = new WindreamSearchToDepartmentRepository();
|
||||
WindreamSearchToDepartmentController controller = new WindreamSearchToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamSearchToDepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchItemToWindreamSearchToDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WindreamSearchItemToWindreamSearchToDepartmentRepository repository = new WindreamSearchItemToWindreamSearchToDepartmentRepository();
|
||||
WindreamSearchItemToWindreamSearchToDepartmentController controller = new WindreamSearchItemToWindreamSearchToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamSearchItemToWindreamSearchToDepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchItemController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WindreamSearchItemRepository repository = new WindreamSearchItemRepository();
|
||||
WindreamSearchItemController controller = new WindreamSearchItemController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamSearchItemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WindreamSearchRepository repository = new WindreamSearchRepository();
|
||||
WindreamSearchController controller = new WindreamSearchController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamSearchId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamIndexToWindreamSearchToDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WindreamIndexToWindreamSearchToDepartmentRepository repository = new WindreamIndexToWindreamSearchToDepartmentRepository();
|
||||
WindreamIndexToWindreamSearchToDepartmentController controller = new WindreamIndexToWindreamSearchToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamIndexToWindreamSearchToDepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamIndexController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WindreamIndexRepository repository = new WindreamIndexRepository();
|
||||
WindreamIndexController controller = new WindreamIndexController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamIndexId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamColumnsToDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WindreamColumnsToDepartmentRepository repository = new WindreamColumnsToDepartmentRepository();
|
||||
WindreamColumnsToDepartmentController controller = new WindreamColumnsToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WindreamColumnsToDepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppToWebAppRoleController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 2;
|
||||
WebAppToWebAppRoleRepository repository = new WebAppToWebAppRoleRepository();
|
||||
WebAppToWebAppRoleController controller = new WebAppToWebAppRoleController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WebAppToWebAppRoleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppToWebAppAdditionalRoleController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 70;
|
||||
WebAppToWebAppAdditionalRoleRepository repository = new WebAppToWebAppAdditionalRoleRepository();
|
||||
WebAppToWebAppAdditionalRoleController controller = new WebAppToWebAppAdditionalRoleController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WebAppToWebAppAdditionalRoleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppToDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 100;
|
||||
WebAppToDepartmentRepository repository = new WebAppToDepartmentRepository();
|
||||
WebAppToDepartmentController controller = new WebAppToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WebAppToDepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppAdditionalRoleController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WebAppAdditionalRoleRepository repository = new WebAppAdditionalRoleRepository();
|
||||
WebAppAdditionalRoleController controller = new WebAppAdditionalRoleController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WebAppAdditionalRoleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeToWebAppController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 300;
|
||||
EmployeeToWebAppRepository repository = new EmployeeToWebAppRepository();
|
||||
EmployeeToWebAppController controller = new EmployeeToWebAppController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.EmployeeToWebAppId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeToDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
EmployeeToDepartmentRepository repository = new EmployeeToDepartmentRepository();
|
||||
EmployeeToDepartmentController controller = new EmployeeToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.EmployeeToDepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeToAttributeController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 100;
|
||||
EmployeeToAttributeRepository repository = new EmployeeToAttributeRepository();
|
||||
EmployeeToAttributeController controller = new EmployeeToAttributeController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.EmployeeToAttributeId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
EmployeeRepository repository = new EmployeeRepository();
|
||||
EmployeeController controller = new EmployeeController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.EmployeeId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetDocumentArtToDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
DocumentArtToDepartmentRepository repository = new DocumentArtToDepartmentRepository();
|
||||
DocumentArtToDepartmentController controller = new DocumentArtToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.DocumentArtToDepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetDepartmentToWebAppToEmployeeForWindreamController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
DepartmentToWebAppToEmployeeForWindreamRepository repository = new DepartmentToWebAppToEmployeeForWindreamRepository();
|
||||
DepartmentToWebAppToEmployeeForWindreamController controller = new DepartmentToWebAppToEmployeeForWindreamController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.DepartmentToWebAppToEmployeeForWindreamId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppRoleController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 10;
|
||||
WebAppRoleRepository repository = new WebAppRoleRepository();
|
||||
WebAppRoleController controller = new WebAppRoleController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WebAppRoleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
WebAppRepository repository = new WebAppRepository();
|
||||
WebAppController controller = new WebAppController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.WebAppId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetRangController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
RangRepository repository = new RangRepository();
|
||||
RangController controller = new RangController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.RangId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetProjectController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
ProjectRepository repository = new ProjectRepository();
|
||||
ProjectController controller = new ProjectController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.ProjectId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeStatusController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
EmployeeStatusRepository repository = new EmployeeStatusRepository();
|
||||
EmployeeStatusController controller = new EmployeeStatusController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.EmployeeStatusId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeAttributeController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
EmployeeAttributeRepository repository = new EmployeeAttributeRepository();
|
||||
EmployeeAttributeController controller = new EmployeeAttributeController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.EmployeeAttributeId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetDocumentArtController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
DocumentArtRepository repository = new DocumentArtRepository();
|
||||
DocumentArtController controller = new DocumentArtController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.DocumentArtId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetDepartmentController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
DepartmentRepository repository = new DepartmentRepository();
|
||||
DepartmentController controller = new DepartmentController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.DepartmentId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetCostCentreController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 100;
|
||||
CostCentreRepository repository = new CostCentreRepository();
|
||||
CostCentreController controller = new CostCentreController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.CostCentreId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task Check_Employee()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 272;
|
||||
var repo = new EmployeeRepository();
|
||||
var entity= await repo.GetByIdAsync(entityId);
|
||||
entity.PhoneNo = "1234";
|
||||
await repo.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetAdWebAppToWebAppRoleController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
int entityId = 1;
|
||||
AdWebAppToWebAppRoleRepository repository = new AdWebAppToWebAppRoleRepository();
|
||||
AdWebAppToWebAppRoleController controller = new AdWebAppToWebAppRoleController(repository);
|
||||
dynamic result = await controller.GetEntityAsync(entityId);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.Result.StatusCode);
|
||||
|
||||
var entity = result.Result.Value;
|
||||
Assert.NotNull(entity);
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.AdWebAppToWebAppRoleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
534
XUnitDAL.Test/Test_Controller_Filter.cs
Normal file
534
XUnitDAL.Test/Test_Controller_Filter.cs
Normal file
@@ -0,0 +1,534 @@
|
||||
using DAL.Models.Filters;
|
||||
using DAL.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using StaffDBServer.Controllers;
|
||||
using Xunit;
|
||||
using XUnitWebApi.SharedConfig;
|
||||
|
||||
namespace XUnitWebApi.Controller
|
||||
{
|
||||
public class Test_Controller_Filter
|
||||
{
|
||||
//----Check_GetEntityFilteredListController
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamInputFolderFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
WindreamInputFolderFilter filter = new WindreamInputFolderFilter();
|
||||
filter.ClientId = 24110;
|
||||
WindreamInputFolderRepository repository = new WindreamInputFolderRepository();
|
||||
WindreamInputFolderController controller = new WindreamInputFolderController(repository);
|
||||
dynamic result = await controller.GetWindreamInputFolderListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchToDepartmentFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
DepartmentFilter filter = new DepartmentFilter();
|
||||
filter.DepartmentId = 16;
|
||||
WindreamSearchToDepartmentRepository repository = new WindreamSearchToDepartmentRepository();
|
||||
WindreamSearchToDepartmentController controller = new WindreamSearchToDepartmentController(repository);
|
||||
dynamic result = await controller.GetWindreamSearchToDepartmentListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchItemToWindreamSearchToDepartmentFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
WindreamSearchToDepartmentFilter filter = new WindreamSearchToDepartmentFilter();
|
||||
filter.DepartmentId = 16;
|
||||
WindreamSearchItemToWindreamSearchToDepartmentRepository repository = new WindreamSearchItemToWindreamSearchToDepartmentRepository();
|
||||
WindreamSearchItemToWindreamSearchToDepartmentController controller = new WindreamSearchItemToWindreamSearchToDepartmentController(repository);
|
||||
dynamic result = await controller.GetWindreamSearchItemToWindreamSearchToDepartmentListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchItemFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
ClientIdFilter filter = new ClientIdFilter();
|
||||
filter.ClientId = 24110;
|
||||
WindreamSearchItemRepository repository = new WindreamSearchItemRepository();
|
||||
WindreamSearchItemController controller = new WindreamSearchItemController(repository);
|
||||
dynamic result = await controller.GetWindreamSearchItemListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamSearchFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
ClientIdFilter filter = new ClientIdFilter();
|
||||
filter.ClientId = 24110;
|
||||
WindreamSearchRepository repository = new WindreamSearchRepository();
|
||||
WindreamSearchController controller = new WindreamSearchController(repository);
|
||||
dynamic result = await controller.GetWindreamSearchListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamIndexToWindreamSearchToDepartmentFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
WindreamSearchToDepartmentFilter filter = new WindreamSearchToDepartmentFilter();
|
||||
filter.DepartmentId = 16;
|
||||
WindreamIndexToWindreamSearchToDepartmentRepository repository = new WindreamIndexToWindreamSearchToDepartmentRepository();
|
||||
WindreamIndexToWindreamSearchToDepartmentController controller = new WindreamIndexToWindreamSearchToDepartmentController(repository);
|
||||
dynamic result = await controller.GetWindreamIndexToWindreamSearchToDepartmentListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamIndexFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
ClientIdFilter filter = new ClientIdFilter();
|
||||
filter.ClientId = 24110;
|
||||
WindreamIndexRepository repository = new WindreamIndexRepository();
|
||||
WindreamIndexController controller = new WindreamIndexController(repository);
|
||||
dynamic result = await controller.GetWindreamIndexListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWindreamColumnsToDepartmentFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
DepartmentFilter filter = new DepartmentFilter();
|
||||
filter.DepartmentId = 16;
|
||||
WindreamColumnsToDepartmentRepository repository = new WindreamColumnsToDepartmentRepository();
|
||||
WindreamColumnsToDepartmentController controller = new WindreamColumnsToDepartmentController(repository);
|
||||
dynamic result = await controller.GetWindreamColumnsToDepartmentListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppToWebAppRoleFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
WebAppFilter filter = new WebAppFilter();
|
||||
filter.WebAppId = 1;
|
||||
WebAppToWebAppRoleRepository repository = new WebAppToWebAppRoleRepository();
|
||||
WebAppToWebAppRoleController controller = new WebAppToWebAppRoleController(repository);
|
||||
dynamic result = await controller.GetWebAppToWebAppRoleListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppToWebAppAdditionalRoleFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeToWebAppFilter filter = new EmployeeToWebAppFilter();
|
||||
filter.EmployeeToWebAppId = 73;
|
||||
WebAppToWebAppAdditionalRoleRepository repository = new WebAppToWebAppAdditionalRoleRepository();
|
||||
WebAppToWebAppAdditionalRoleController controller = new WebAppToWebAppAdditionalRoleController(repository);
|
||||
dynamic result = await controller.GetWebAppToWebAppAdditionalRoleListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppToDepartmentFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeToWebAppFilter filter = new EmployeeToWebAppFilter();
|
||||
filter.EmployeeToWebAppId = 39;
|
||||
WebAppToDepartmentRepository repository = new WebAppToDepartmentRepository();
|
||||
WebAppToDepartmentController controller = new WebAppToDepartmentController(repository);
|
||||
dynamic result = await controller.GetWebAppToDepartmentListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetWebAppAdditionalRoleFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
WebAppFilter filter = new WebAppFilter();
|
||||
filter.WebAppId = 3;
|
||||
WebAppAdditionalRoleRepository repository = new WebAppAdditionalRoleRepository();
|
||||
WebAppAdditionalRoleController controller = new WebAppAdditionalRoleController(repository);
|
||||
dynamic result = await controller.GetWebAppAdditionalRoleListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeToWebAppFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeFilter filter = new EmployeeFilter();
|
||||
filter.LoginName = "y.kochetenko";
|
||||
EmployeeToWebAppRepository repository = new EmployeeToWebAppRepository();
|
||||
EmployeeToWebAppController controller = new EmployeeToWebAppController(repository);
|
||||
dynamic result = await controller.GetEmployeeToWebAppListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeToDepartmentFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeFilter filter = new EmployeeFilter();
|
||||
filter.EmployeeId = 29;
|
||||
EmployeeToDepartmentRepository repository = new EmployeeToDepartmentRepository();
|
||||
EmployeeToDepartmentController controller = new EmployeeToDepartmentController(repository);
|
||||
dynamic result = await controller.GetEmployeeToDepartmentListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeToAttributeFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeFilter filter = new EmployeeFilter();
|
||||
filter.EmployeeId = 29;
|
||||
EmployeeToAttributeRepository repository = new EmployeeToAttributeRepository();
|
||||
EmployeeToAttributeController controller = new EmployeeToAttributeController(repository);
|
||||
dynamic result = await controller.GetEmployeeToAttributeListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeFilteredClientIdController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeFullFilter filter = new EmployeeFullFilter();
|
||||
filter.ClientId = 24110;
|
||||
EmployeeRepository repository = new EmployeeRepository();
|
||||
EmployeeController controller = new EmployeeController(repository);
|
||||
dynamic result = await controller.GetEmployeeListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeFilteredisActive()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeFullFilter filter = new EmployeeFullFilter();
|
||||
filter.IsActive = false;
|
||||
EmployeeRepository repository = new EmployeeRepository();
|
||||
EmployeeController controller = new EmployeeController(repository);
|
||||
dynamic result = await controller.GetEmployeeListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetEmployeeFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeFullFilter filter = new EmployeeFullFilter();
|
||||
filter.Name = "";
|
||||
EmployeeRepository repository = new EmployeeRepository();
|
||||
EmployeeController controller = new EmployeeController(repository);
|
||||
dynamic result = await controller.GetEmployeeListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetDocumentArtToDepartmentFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
DepartmentFilter filter = new DepartmentFilter();
|
||||
filter.DepartmentId = 16;
|
||||
DocumentArtToDepartmentRepository repository = new DocumentArtToDepartmentRepository();
|
||||
DocumentArtToDepartmentController controller = new DocumentArtToDepartmentController(repository);
|
||||
dynamic result = await controller.GetDocumentArtToDepartmentListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Check_GetDepartmentToWebAppToEmployeeForWindreamFilteredListController()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
EmployeeFilter filter = new EmployeeFilter();
|
||||
filter.EmployeeId = 29;
|
||||
DepartmentToWebAppToEmployeeForWindreamRepository repository = new DepartmentToWebAppToEmployeeForWindreamRepository();
|
||||
DepartmentToWebAppToEmployeeForWindreamController controller = new DepartmentToWebAppToEmployeeForWindreamController(repository);
|
||||
dynamic result = await controller.GetDepartmentToWebAppToEmployeeForWindreamListAsync(filter);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
XUnitDAL.Test/XUnitWebApi.Test.csproj
Normal file
27
XUnitDAL.Test/XUnitWebApi.Test.csproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||
<PackageReference Include="xunit" Version="2.8.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DAL\DAL.csproj" />
|
||||
<ProjectReference Include="..\StaffDBServer\StaffDBServer.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
89
XUnitDAL.Test/_Shared/Shared_Test_Controller_Generic.cs
Normal file
89
XUnitDAL.Test/_Shared/Shared_Test_Controller_Generic.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Xunit;
|
||||
using XUnitWebApi.SharedConfig;
|
||||
using XUnitWebApi.SharedUtils;
|
||||
|
||||
namespace XUnitWebApi.SharedController
|
||||
{
|
||||
public class Shared_Test_Controller_Generic
|
||||
{
|
||||
[Theory()]
|
||||
[InlineData("")]
|
||||
[InlineData("AdWebAppToWebAppRole")]
|
||||
[InlineData("CostCentre")]
|
||||
[InlineData("Department")]
|
||||
[InlineData("DocumentArt")]
|
||||
[InlineData("EmployeeAttribute")]
|
||||
[InlineData("EmployeeStatus")]
|
||||
[InlineData("Project")]
|
||||
[InlineData("Rang")]
|
||||
[InlineData("WebApp")]
|
||||
[InlineData("WebAppRole")]
|
||||
[InlineData("DepartmentToWebAppToEmployeeForWindream")]
|
||||
[InlineData("DocumentArtToDepartment")]
|
||||
[InlineData("Employee")]
|
||||
[InlineData("EmployeeToAttribute")]
|
||||
[InlineData("EmployeeToDepartment")]
|
||||
[InlineData("EmployeeToWebApp")]
|
||||
[InlineData("WebAppAdditionalRole")]
|
||||
[InlineData("WebAppToDepartment")]
|
||||
[InlineData("WebAppToWebAppAdditionalRole")]
|
||||
[InlineData("WebAppToWebAppRole")]
|
||||
[InlineData("WindreamColumnsToDepartment")]
|
||||
[InlineData("WindreamIndex")]
|
||||
[InlineData("WindreamIndexToWindreamSearchToDepartment")]
|
||||
[InlineData("WindreamSearch")]
|
||||
[InlineData("WindreamSearchItem")]
|
||||
[InlineData("WindreamSearchItemToWindreamSearchToDepartment")]
|
||||
[InlineData("WindreamSearchToDepartment")]
|
||||
[InlineData("WindreamInputFolder")]
|
||||
[InlineData("Subsidiary")]
|
||||
public async Task Check_Dynamic_EntityControllers(string entityName = "", int entityId = 0)
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
string actualEntity = "";
|
||||
List<string> ExceptionList = new List<string>();
|
||||
|
||||
var typeList = TestHelper.GetAllRepositories().Select(t => t.Name.Replace("Repository", ""));
|
||||
|
||||
foreach (var item in typeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
actualEntity = item;
|
||||
if (entityName == "" || item == entityName)
|
||||
{
|
||||
dynamic repository = TestHelper.GetRepository_BasedOn_BaseRepository(item);
|
||||
if (repository == null) continue;
|
||||
dynamic controller = TestHelper.GetApiController_BasedOn_BaseController(item, repository);
|
||||
if (controller == null) continue;
|
||||
dynamic result;
|
||||
if (entityId > 0)
|
||||
{
|
||||
result = await controller.GetEntityAsync(entityId);
|
||||
result = result?.Result;
|
||||
}
|
||||
else result = await controller.GetAllAsync();
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(StatusCodes.Status200OK, result.StatusCode);
|
||||
|
||||
var entity = result.Value;
|
||||
Assert.NotNull(entity);
|
||||
|
||||
if (entityId > 0) Assert.Equal(entityId, entity.GetEntityId());
|
||||
else Assert.NotEqual(entity.Count, 0);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//throw new Exception(actualEntity, ex);
|
||||
Console.WriteLine(ex.Message);
|
||||
ExceptionList.Add($"Entity: {actualEntity} " + ex.Message + " " + ex.InnerException);
|
||||
}
|
||||
}
|
||||
var errList = "";
|
||||
foreach (var item in ExceptionList) errList += "\r\n -- " + item;
|
||||
if (ExceptionList.Count > 0) throw new Exception(errList);
|
||||
}
|
||||
}
|
||||
}
|
||||
88
XUnitDAL.Test/_Shared/Shared_Test_DAL.cs
Normal file
88
XUnitDAL.Test/_Shared/Shared_Test_DAL.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using DAL;
|
||||
using DAL._Shared.SharedRepositories;
|
||||
using HRD.WebApi;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
using XUnitWebApi.SharedConfig;
|
||||
using XUnitWebApi.SharedUtils;
|
||||
|
||||
namespace XUnitWebApi.SahredDAL
|
||||
{
|
||||
public class Shared_Test_DAL
|
||||
{
|
||||
[Fact]
|
||||
public async System.Threading.Tasks.Task Check_Repository_XXXAsync()
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
|
||||
|
||||
var res = await webAppUserRepository.TakeListAsync(2);
|
||||
Assert.NotEmpty(res);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Check_Repository_By_Name()
|
||||
{
|
||||
var res = Check_Repositories(0, true, "Case");
|
||||
Assert.True(res);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Check_All_Repositories()
|
||||
{
|
||||
var res = Check_Repositories(0, true);
|
||||
Assert.True(res);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Check_All_Repositories_With_Values()
|
||||
{
|
||||
var res = Check_Repositories(1, true);
|
||||
Assert.True(res);
|
||||
}
|
||||
|
||||
private bool Check_Repositories(int count = 0, bool raiseRepositoryExceptions = false, string repositoryName = "", string namespaceName = "DAL.Repositories")
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
WebApiConfig.RaiseRepositoryExceptions = raiseRepositoryExceptions;
|
||||
|
||||
string entityName = string.Empty;
|
||||
|
||||
List<string> ExceptionList = new List<string>();
|
||||
|
||||
using WebApiContext ctx = new WebApiContext();
|
||||
{
|
||||
Assert.True(ctx.Database.CanConnect());
|
||||
var typeList = TestHelper.GetAllRepositories(namespaceName);
|
||||
|
||||
foreach (var item in typeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (repositoryName == "" || item.Name.Contains(repositoryName))
|
||||
{
|
||||
Type type = item as Type;
|
||||
entityName = type.Name;
|
||||
object instance = Activator.CreateInstance(type);
|
||||
MethodInfo takeListMethod = type.GetMethod("TakeList");
|
||||
dynamic list = takeListMethod.Invoke(instance, new object[] { count, true });
|
||||
System.Diagnostics.Debug.WriteLine(entityName);
|
||||
Assert.NotNull(list);
|
||||
Assert.Equal(count, list.Count);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
ExceptionList.Add($"Entity: {entityName} " + ex.Message + " " + ex.InnerException);
|
||||
}
|
||||
}
|
||||
}
|
||||
var errList = "";
|
||||
foreach (var item in ExceptionList) errList += "\r\n -- " + item;
|
||||
if (ExceptionList.Count > 0) throw new Exception(errList);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
98
XUnitDAL.Test/_Shared/Shared_Test_LDAP.cs
Normal file
98
XUnitDAL.Test/_Shared/Shared_Test_LDAP.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using DAL._Shared.SharedModels;
|
||||
using DAL._Shared.SharedRepositories;
|
||||
using HRD.LDAPService;
|
||||
using HRD.LDAPService.JWT;
|
||||
using StaffDBServer.SharedControllers;
|
||||
using Xunit;
|
||||
using XUnitWebApi.SharedConfig;
|
||||
|
||||
namespace XUnitWebApi.SharedLDAP
|
||||
{
|
||||
public class Shared_Test_LDAP
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("user", "pwd")]
|
||||
[InlineData("user2", "pwd")]
|
||||
public async System.Threading.Tasks.Task Validate_Credentials_WebAppUser(string login, string passwort)
|
||||
{
|
||||
Shared_Test_Config.Init_Webapi_Context();
|
||||
|
||||
try
|
||||
{
|
||||
WebAppUser userFromClient = new WebAppUser(
|
||||
login,
|
||||
login,
|
||||
"User",
|
||||
login);
|
||||
userFromClient.Password = passwort;
|
||||
|
||||
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository = new WebAppEmployeeInfoRepository();
|
||||
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == userFromClient.LoginName);
|
||||
Assert.NotNull(webAppEmployeeInfo);
|
||||
|
||||
WebAppUserHelper webAppUserHelper = new WebAppUserHelper();
|
||||
LdapUser ldapUserFromClient = new LdapUser(userFromClient.LoginName, webAppEmployeeInfo.EmployeeId, userFromClient.Password, webAppEmployeeInfo.DepartmentId, webAppEmployeeInfo.ExtendedDepartmentIdList);
|
||||
Assert.NotNull(ldapUserFromClient);
|
||||
|
||||
bool ldapUserOk = JwtManager.GenerateLdapUserWithJwtToken(ldapUserFromClient);
|
||||
Assert.True(ldapUserOk);
|
||||
|
||||
WebAppUser newUser = await webAppUserHelper.CheckLoginWithNameAndPasswordAsync(userFromClient);
|
||||
|
||||
Assert.NotNull(newUser);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("visitoripad", "pwd")]
|
||||
public void Validate_Credentials_with_password(string login, string passwort)
|
||||
{
|
||||
try
|
||||
{
|
||||
LdapUser ldapUser = new LdapUser(login, 0, passwort);
|
||||
var result = LdapAuthenticationService.CheckAndUpdateIdentityWithPassword(ldapUser);
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetLdapUsers))]
|
||||
public void Validate_Credentials_with_password_Version2(LdapUser ldapUser)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = LdapAuthenticationService.CheckAndUpdateIdentityWithPassword(ldapUser);
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> GetLdapUsers()
|
||||
{
|
||||
LdapUser ldapUser = new LdapUser("user1", 0, "pwd");
|
||||
LdapUser ldapUser2 = new LdapUser("Error", 0, "pwd");
|
||||
|
||||
var allData = new List<object[]>
|
||||
{
|
||||
new object[] { ldapUser },
|
||||
new object[] { ldapUser2 }
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
XUnitDAL.Test/_Shared/Shared_Utils.cs
Normal file
46
XUnitDAL.Test/_Shared/Shared_Utils.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
namespace XUnitWebApi.SharedUtils
|
||||
{
|
||||
public static class TestHelper
|
||||
{
|
||||
public static IEnumerable<Type> GetAllRepositories(string namespaceName = "DAL.Repositories")
|
||||
{
|
||||
var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes())
|
||||
.Where(t => t.IsClass && !t.Name.StartsWith("<")
|
||||
&& (t.Namespace == namespaceName || t.Namespace == "DAL.SharedRepositories")
|
||||
);
|
||||
return types;
|
||||
}
|
||||
|
||||
public static dynamic GetApiController_BasedOn_BaseController(string controllerName, dynamic repository)
|
||||
{
|
||||
var typeList = AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes())
|
||||
.Where(t => t.IsClass && !t.Name.StartsWith("<"))
|
||||
.Where(t => t.Name.Contains("Controller"))
|
||||
.Where(t => t.BaseType.Name.StartsWith("BaseController"))
|
||||
.Where(t => controllerName == "" || t.Name == controllerName + "Controller");
|
||||
//var entityTypes = typeList.ToList();
|
||||
//var entityType = entityTypes.Where(t => controllerName == "" || t.Name.Contains(controllerName)).FirstOrDefault();
|
||||
var entityType = typeList.FirstOrDefault();
|
||||
if (entityType == default) return default;
|
||||
Type type = entityType as Type;
|
||||
dynamic instance = Activator.CreateInstance(type, new object[] { repository });
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static dynamic GetRepository_BasedOn_BaseRepository(string repositoryName)
|
||||
{
|
||||
var typeList = AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes())
|
||||
.Where(t => t.IsClass && !t.Name.StartsWith("<"))
|
||||
.Where(t => repositoryName == "" || t.Name == repositoryName + "Repository")
|
||||
.Where(t => t.Name.Contains("Repository"))
|
||||
.Where(t => t.BaseType.Name.StartsWith("BaseRepository"));
|
||||
var entityType = typeList.FirstOrDefault();
|
||||
if (entityType == default) return default;
|
||||
Type type = entityType as Type;
|
||||
dynamic instance = Activator.CreateInstance(type);
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
XUnitDAL.Test/_Shared/Shared_test_config.cs
Normal file
41
XUnitDAL.Test/_Shared/Shared_test_config.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using HRD.AppLogger;
|
||||
using HRD.LDAPService;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace XUnitWebApi.SharedConfig
|
||||
{
|
||||
public static class Shared_Test_Config
|
||||
{
|
||||
public static void Init_Webapi_Context()
|
||||
{
|
||||
if (WebApiConfig.Connectionstring != default) return; //all test are running simultain using the same WebApiConfig, therefore it must be initialised only one time
|
||||
var app_path = Directory.GetCurrentDirectory();
|
||||
var pos = app_path.IndexOf("XUnitDAL.Test");
|
||||
if (pos >= 0) app_path = app_path.Remove(pos);
|
||||
app_path += "StaffDBServer\\appsettings.json";
|
||||
|
||||
IConfiguration configuration = new ConfigurationBuilder().AddJsonFile(app_path, true, true).Build();
|
||||
WebApiConfig.Init(configuration);
|
||||
|
||||
WebApiConfig.AssemblyName = "KabionlineServer_test";
|
||||
WebApiConfig.AssemblyVersion = "xxx.xx";
|
||||
//WebApiConfig.Connectionstring = Config_ConnectionString;
|
||||
//WebApiConfig.NlogConnectionstring = Config_ConnectionString;
|
||||
WebApiConfig.NlogDBLogLevel = EN_LoggingLevel.Error;
|
||||
WebApiConfig.NlogFileLogLevel = EN_LoggingLevel.Off;
|
||||
WebApiConfig.RaiseRepositoryExceptions = false;
|
||||
|
||||
//JWT#1
|
||||
var jwtRoleList = new List<JwtRole>();
|
||||
var ADGroupPrefix = WebApiConfig.IsLive ? "" : "__Test";
|
||||
//jwtRoleList.Add(new JwtRole(JwtGlobals.ROLE_USER, "GG_WebApp" + ADGroupPrefix + "_Kabionline_User")); //(RO) nur eigene
|
||||
//jwtRoleList.Add(new JwtRole(JwtGlobals.ROLE_MASTER, "GG_WebApp" + ADGroupPrefix + "_Kabionline_Master")); //RW ALLE Abteilungen
|
||||
//jwtRoleList.Add(new JwtRole(JwtGlobals.ROLE_DEPARTMENTUSER, "GG_WebApp" + ADGroupPrefix + "_Kabionline_DepartmentUser")); //(RW) auch andere aus eigener Abteilung
|
||||
//jwtRoleList.Add(new JwtRole(JwtGlobals.ROLE_DEPARTMENTMASTER, "GG_WebApp" + ADGroupPrefix + "_Kabionline_DepartmentMaster")); //(RW) auch andere aus eigener Abteilung
|
||||
|
||||
JwtTokenConfig.JwtRoleList = jwtRoleList;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user