109 lines
3.8 KiB
C#
109 lines
3.8 KiB
C#
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Moq;
|
|
using Sarand.BusinessMgr.Net.Core.Web.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
|
using Sarand.BusinessMgr.Web.Control.App;
|
|
using Sarand.BusinessMgr.Web.Control.Consoles;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Dbas;
|
|
using System;
|
|
|
|
namespace Sarand.BusinessMgr.Test.Web.Control.App
|
|
{
|
|
public class SbmApplication_Tester_Base : SacsDisposable
|
|
{
|
|
// --- Definitions ---
|
|
|
|
private class SbmApplication_Control_Test : SbmApplication_Control
|
|
{
|
|
public SbmApplication_Control_Test(IConfiguration configuration, IWebHostEnvironment env) :
|
|
base(configuration)
|
|
{
|
|
InitEnvironment(env);
|
|
}
|
|
}
|
|
|
|
// --- Construction ---
|
|
|
|
protected SbmApplication_Tester_Base()
|
|
{
|
|
// Application.
|
|
Mock<IConfiguration> mockConfiguration = new Mock<IConfiguration>();
|
|
Mock<IWebHostEnvironment> mockEnvironment = new Mock<IWebHostEnvironment>();
|
|
mockEnvironment.Setup(m => m.EnvironmentName).Returns(Environments.Development);
|
|
mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2022\BusinessMgr\Workspace\SaBusinessMgrCoreWebControl");
|
|
App_Control = new SbmApplication_Control_Test(mockConfiguration.Object, mockEnvironment.Object);
|
|
Internals_Control = new SbmInternals_Control();
|
|
|
|
// Control session data, matching the minimal session used by the serialization tests.
|
|
SbmcAccountMgr accountMgr = Internals_Control.ControlAccountMgr;
|
|
SbmcUserAccount userAccount = accountMgr.GetUserAccountByEmailAddress("andy@sarand.com");
|
|
SessionData_Control = new SbmSessionData_Control(null, userAccount);
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
Internals_Control.Dispose();
|
|
}
|
|
}
|
|
|
|
// --- Properties ---
|
|
|
|
protected SbmApplication App { get { return App_Control; } }
|
|
protected SbmApplication_Web App_Web { get { return App_Control; } }
|
|
protected SbmApplication_Control App_Control { get; }
|
|
protected SbmSessionData_Control SessionData_Control { get; private set; }
|
|
protected SbmInternals_Control Internals_Control { get; private set; }
|
|
|
|
// --- Utilities ---
|
|
|
|
protected SbmInternals_Control CreateInternalsControl() { return new SbmInternals_Control(); }
|
|
|
|
// --- Core Instance Console ---
|
|
|
|
protected SbmCoreInstanceConsole_Control CreateCoreInstanceConsole(String repositoryContext)
|
|
{
|
|
SbmcRepository repository = Internals_Control.ControlInstanceMgr.GetRepositoryByContext(repositoryContext);
|
|
return new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
|
|
}
|
|
|
|
// --- Repositories ---
|
|
|
|
/// <summary>
|
|
/// Retrieve an active repository, randomly selected.
|
|
/// </summary>
|
|
protected SbmcRepository GetRandomActiveRepository()
|
|
{
|
|
// Repository.
|
|
SbmcRepository.Params prmRepository = new SbmcRepository.Params();
|
|
prmRepository.StatusCat = SbmcRepository.StatusCat.ActiveOnly;
|
|
prmRepository.RandomOrder = true;
|
|
prmRepository.ResultsPaging.Set(1, 1);
|
|
return Internals_Control.ControlInstanceMgr.GetRepositoryList(prmRepository).First();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve an active repository by context.
|
|
/// </summary>
|
|
protected SbmcRepository GetActiveRepositoryByContext(String repositoryContext)
|
|
{
|
|
// Repository.
|
|
SbmcRepository.Params prmRepository = new SbmcRepository.Params();
|
|
prmRepository.ContextsIncluded.Add(repositoryContext);
|
|
prmRepository.StatusCat = SbmcRepository.StatusCat.ActiveOnly;
|
|
prmRepository.ResultsPaging.Set(1, 1);
|
|
return Internals_Control.ControlInstanceMgr.GetRepositoryList(prmRepository).First();
|
|
}
|
|
|
|
// --- The End ---
|
|
}
|
|
}
|