Files
BusinessMgr-2019/SaBusMgrTest_Control/Web/Control/App/SbmApplication_Tester.cs
T

143 lines
5.4 KiB
C#

using Microsoft.VisualStudio.TestTools.UnitTesting;
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.Consoles;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
using Sarand.BusinessMgr.Web.Control.Consoles;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Security;
namespace Sarand.BusinessMgr.Test.Web.Control.App
{
//=======================================================================
[TestClass]
public class SbmApplication_Tester : SbmApplication_Tester_Base
{
//-------------------------------------------------------------------
[TestMethod]
public void Test_Application_Application()
{
// Application.
Assert.IsNotNull(App);
Assert.IsNotNull(App_Web);
Assert.IsNotNull(App_Control);
}
//-------------------------------------------------------------------
[TestMethod]
public void Test_Application_ControlDatabase()
{
// Control database.
ISacsDatabase db = App.GetControlDatabase();
Assert.IsNotNull(db);
// Tables.
Assert.IsTrue(db.TableExists(SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.Owner)));
Assert.IsTrue(db.TableExists(SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.Repository)));
}
//-------------------------------------------------------------------
[TestMethod]
public void Test_Application_TemplateDatabase()
{
// Template database.
ISacsDatabase db = App.GetTemplateDatabase();
Assert.IsNotNull(db);
// Tables.
Assert.IsTrue(db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate)));
Assert.IsTrue(db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity)));
Assert.IsTrue(db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction, false)));
Assert.IsTrue(db.TableExists(SaSecurityDbDfn.GetTableName(SaSecurityDbDfn.TableIdx.SaSecItem)));
}
//-------------------------------------------------------------------
[TestMethod]
public void Test_Application_Internals_Control()
{
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
{
// Control internals.
Assert.IsNotNull(Internals_Control);
// Owners.
Assert.IsNotNull(Internals_Control.ControlInstanceMgr);
SbmcOwner.Params prmOwner = new SbmcOwner.Params();
prmOwner.StatusCat = SbmcOwner.StatusCat.ActiveOnly;
Assert.IsTrue(Internals_Control.ControlInstanceMgr.GetOwnerCount(prmOwner) > 0);
// Repositories.
Assert.IsNotNull(Internals_Control.ControlInstanceMgr);
SbmcRepository.Params prmRepository = new SbmcRepository.Params();
prmRepository.StatusCat = SbmcRepository.StatusCat.ActiveOnly;
Assert.IsTrue(Internals_Control.ControlInstanceMgr.GetRepositoryCount(prmRepository) > 0);
}
}
//-------------------------------------------------------------------
[TestMethod]
public void Test_Application_CoreInstanceConsole()
{
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
{
// Repository.
SbmcRepository repository = GetRandomActiveRepository();
Assert.IsNotNull(repository);
// Instance console.
SbmCoreInstanceConsole instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
disposables.Add(instanceConsole);
Assert.IsNotNull(instanceConsole);
}
}
//-------------------------------------------------------------------
[TestMethod]
public void Test_Application_Internals_Core()
{
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
{
// Repository.
SbmcRepository repository = GetRandomActiveRepository();
Assert.IsNotNull(repository);
// Instance console.
SbmCoreInstanceConsole instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
disposables.Add(instanceConsole);
Assert.IsNotNull(instanceConsole);
}
}
//-------------------------------------------------------------------
[TestMethod]
public void Test_Application_SessionContexts()
{
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
{
// Repository.
SbmcRepository repository = GetRandomActiveRepository();
Assert.IsNotNull(repository);
SbmCoreInstanceConsole instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
disposables.Add(instanceConsole);
Assert.IsNotNull(instanceConsole);
// Session Context.
ushort sessionIdx = App_Control.GetCoreSessionIndexForControlRepository(repository.OwnerId, repository.Id);
SbmSessionContext sessionContext = App_Control.GetSessionContextByIndex(sessionIdx);
Assert.IsNotNull(sessionContext);
Assert.AreEqual(sessionIdx, sessionContext.Index);
}
}
//-------------------------------------------------------------------
}
//=======================================================================
}