DatabaseTestBase Class |
Namespace: PDTec.IceNet.Sdk.Test
public abstract class DatabaseTestBase
The DatabaseTestBase type exposes the following members.
Name | Description | |
---|---|---|
DatabaseTestBase |
Creates a test class instance.
|
Name | Description | |
---|---|---|
BOAssemblyNames |
Gets the list of BO assemblies to be loaded for the test.
| |
BOFactories |
Gets the list of BO factories to be loaded for the test.
| |
DatabaseName |
Gets or sets the SQL Server database name.
| |
LicenseFilePath |
Gets or sets the license file path.
| |
Login |
Gets the login information. If you want to use trusted connection login on the local
machine, there is no need to set anything here.
| |
Repository |
Gets the repository entry point for the test.
| |
ServerName |
Gets or sets the SQL Server instance name. Default is (local)\SQLEXPRESS.
| |
TestDatabaseSettings | ||
UserName |
Gets or sets the name of the user that is used to access the ice.NET
infrastructure.
|
Name | Description | |
---|---|---|
CreateRepository |
Creates a new repository entry point for the test.
| |
CreateRepositoryFactory |
Creates a repository factory.
| |
DiscardCurrentRepository |
Resets the repository entry point reference. Subsequent access
of Repository will create a new instance.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ImportData |
Imports data from a resource XML file.
| |
ImportModel |
Imports a data model fron a resource XML file.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
SetUpBase |
Undecorated SetUp method. Override this method, call base.SetUpBase() and
decorate it with a unit testing attribute.
| |
TearDownBase |
Undecorated TearDown method. Override this method, call base.TearDownBase() and
decorate it with a unit testing attribute.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
This example shows how to create an application-specific unit test base class. The class defines the database name to be used for testing ("test_db01"), sets the path to the license file, ensures that the relevant business objects assemblies ("PDTec.IceNet.Domain", "PDTec.ICR.BusinessLogic") are loaded and that the SetUp and TearDown methods are connected with the unit testing framework by code attributes.
public abstract class DatabaseTestBase : PDTec.IceNet.Sdk.Test.DatabaseTestBase { public DatabaseTestBase() : base("test_db01") { LicenseFilePath = @"..\..\..\..\license.xml"; BOAssemblyNames.Add("PDTec.IceNet.Domain"); BOAssemblyNames.Add("PDTec.ICR.BusinessLogic"); } [SetUp] protected override void SetUpBase() { base.SetUpBase(); } [TearDown] protected override void TearDownBase() { base.TearDownBase(); } }
This example shows how to use the base class defined above to create a test fixture. In the fixture-specific SetUp method the basic model and data is imported. In the test case two business object methods (IVehicle.CreateBooking, IBooking.CreateReceipt) are tested.
[TestFixture] public class BookingsTest : DatabaseTestBase { [SetUp] public void SetUp() { Repository.ExecuteTransaction(delegate { ImportModel(Assembly.Load("PDTec.ICR.BusinessLogic"), "PDTec.ICR.BusinessLogic.ModelXml.PDTec.ICR.icemodel"); ImportData(GetType().Assembly, "PDTec.ICR.Test.MasterData.ICR.Data.icedata"); }); } [Test] public void MakeBooking() { Repository.ExecuteTransaction(delegate { ICustomer pCustomer = Repository.GetFolderByKey(Constants.Folder.Customers).Get<ICustomer>(Repository.GetObjTypeByName("PDTec.ICR.Customer"), true, 1)[0]; IVehicle pVehicle = Repository.GetFolderByKey(Constants.Folder.Cars).Get<IVehicle>(Repository.GetObjTypeByName("PDTec.ICR.Vehicle"), true, 1)[0]; IBooking pBooking = pVehicle.CreateBooking(pCustomer, DateTime.UtcNow, DateTime.UtcNow.AddDays(2.0)); pBooking.CreateReceipt("System.Database"); }); Assert.That(Repository.RootFolder.GetChildFolders().Length, Is.GreaterThan(0)); Assert.That(ModelUtils.GetObjectsOfType(Repository, Repository.GetObjTypeByName("PDTec.ICR.Booking"), true, FindRange.Global, null, -1).Length, Is.EqualTo(1)); Assert.That(ModelUtils.GetObjectsOfType(Repository, Repository.GetObjTypeByName("Core.File"), true, FindRange.Global, null, -1).Length, Is.EqualTo(1)); } }