Files

135 lines
4.8 KiB
C#

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.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
{
[TestFixture]
public class SbmApplication_Tester : SbmApplication_Tester_Base
{
// --- Tests ---
[Test]
public void Test_Application_Application()
{
// Application.
Assert.That(App, Is.Not.Null);
Assert.That(App_Web, Is.Not.Null);
Assert.That(App_Control, Is.Not.Null);
Assert.That(SessionData_Control, Is.Not.Null);
Assert.That(SessionData_Control.User, Is.Not.Null);
}
[Test]
public void Test_Application_ControlDatabase()
{
// Control database.
ISacsDatabase db = App.GetControlDatabase();
Assert.That(db, Is.Not.Null);
// Tables.
Assert.That(db.TableExists(SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.Owner)), Is.True);
Assert.That(db.TableExists(SbmDbDfn_Control.GetTableName(SbmDbDfn_Control.TableIdx.Repository)), Is.True);
}
[Test]
public void Test_Application_TemplateDatabase()
{
// Template database.
ISacsDatabase db = App.GetTemplateDatabase();
Assert.That(db, Is.Not.Null);
// Tables.
Assert.That(db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate)), Is.True);
Assert.That(db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity)), Is.True);
Assert.That(db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction, false)), Is.True);
Assert.That(db.TableExists(SaSecurityDbDfn.GetTableName(SaSecurityDbDfn.TableIdx.SaSecItem)), Is.True);
}
[Test]
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.That(Internals_Control, Is.Not.Null);
// Owners.
Assert.That(Internals_Control.ControlInstanceMgr, Is.Not.Null);
SbmcOwner.Params prmOwner = new SbmcOwner.Params();
prmOwner.StatusCat = SbmcOwner.StatusCat.ActiveOnly;
Assert.That(Internals_Control.ControlInstanceMgr.GetOwnerCount(prmOwner) > 0, Is.True);
// Repositories.
Assert.That(Internals_Control.ControlInstanceMgr, Is.Not.Null);
SbmcRepository.Params prmRepository = new SbmcRepository.Params();
prmRepository.StatusCat = SbmcRepository.StatusCat.ActiveOnly;
Assert.That(Internals_Control.ControlInstanceMgr.GetRepositoryCount(prmRepository) > 0, Is.True);
}
}
[Test]
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.That(repository, Is.Not.Null);
// Instance console.
SbmCoreInstanceConsole instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
disposables.Add(instanceConsole);
Assert.That(instanceConsole, Is.Not.Null);
}
}
[Test]
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.That(repository, Is.Not.Null);
// Instance console.
SbmCoreInstanceConsole instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
disposables.Add(instanceConsole);
Assert.That(instanceConsole, Is.Not.Null);
}
}
[Test]
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.That(repository, Is.Not.Null);
SbmCoreInstanceConsole instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
disposables.Add(instanceConsole);
Assert.That(instanceConsole, Is.Not.Null);
// Session Context.
ushort sessionIdx = App_Control.GetCoreSessionIndexForControlRepository(repository.Id);
SbmSessionContext sessionContext = App_Control.GetSessionContextByIndex(sessionIdx);
Assert.That(sessionContext, Is.Not.Null);
Assert.That(sessionContext.Index, Is.EqualTo(sessionIdx));
}
}
// --- The End ---
}
}