9using System.Collections.Generic;
15using Microsoft.VisualStudio.TestTools.UnitTesting;
18using TestClass = NUnit.Framework.TestFixtureAttribute;
19using TestInitialize = NUnit.Framework.SetUpAttribute;
20using TestCleanup = NUnit.Framework.TearDownAttribute;
21using TestMethod = NUnit.Framework.TestAttribute;
34 _testDIContext = TestDIContextFactory.CreateDefaultContext();
38 [TestCategory(
"SkipWhenLiveUnitTesting")]
48 Assert.IsNotNull(obj,
"Failed to get object with no criteria");
53 [TestCategory(
"SkipWhenLiveUnitTesting")]
63 Assert.IsNotNull(obj,
"Failed to get object with criteria");
68 [TestCategory(
"SkipWhenLiveUnitTesting")]
78 Assert.IsNotNull(obj,
"Failed to get object with other criteria");
83 [TestCategory(
"SkipWhenLiveUnitTesting")]
93 Assert.IsNotNull(obj,
"Failed to get object with null criteria");
98 [TestCategory(
"SkipWhenLiveUnitTesting")]
108 Assert.IsNotNull(obj,
"Failed to get object with no criteria");
113 [TestCategory(
"SkipWhenLiveUnitTesting")]
123 Assert.IsNotNull(obj,
"Failed to get object with criteria");
128 [TestCategory(
"SkipWhenLiveUnitTesting")]
138 Assert.IsNotNull(obj,
"Failed to get object with other criteria");
153 return dataPortal.
Create();
158 return dataPortal.
Create(
new Criteria());
163 return dataPortal.
Create(
new OtherCriteria());
168 return dataPortal.
Fetch();
173 return dataPortal.
Fetch(
null);
178 return dataPortal.
Fetch(
new Criteria());
183 return dataPortal.
Fetch(
new OtherCriteria());
187 private class Criteria
192 private class OtherCriteria
200 BusinessRules.CheckRules();
206 if (criteria ==
null)
211 BusinessRules.CheckRules();
218 BusinessRules.CheckRules();
221 private void DataPortal_Fetch()
223 TestResults.Add(
"Fetch",
"No criteria");
228 if (criteria ==
null)
234 private void DataPortal_Fetch(Criteria criteria)
This is the base class from which most business objects will be derived.
void CreateWithCriteria()
void CreateWithOtherCriteria()
void FetchWithOtherCriteria()
static void ClassInitialize(TestContext context)
static TestBizObj NewNoCriteria(IDataPortal< TestBizObj > dataPortal)
static TestBizObj GetNullCriteria(IDataPortal< TestBizObj > dataPortal)
override object GetIdValue()
Override this method to return a unique identifying value for this object.
void DataPortal_Fetch(object criteria)
static TestBizObj NewOtherCriteria(IDataPortal< TestBizObj > dataPortal)
static TestBizObj GetCriteria(IDataPortal< TestBizObj > dataPortal)
static TestBizObj NewCriteria(IDataPortal< TestBizObj > dataPortal)
static TestBizObj GetNoCriteria(IDataPortal< TestBizObj > dataPortal)
static TestBizObj GetOtherCriteria(IDataPortal< TestBizObj > dataPortal)
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
static void Reinitialise()
Reinitialise the dictionary, clearing any existing results, ready for the next test
static string GetResult(string key)
Get a result of an operation from the underlying results dictionary
static void Add(string key, string value)
Add an item to the test results, to indicate an outcome of a particular operation
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
object Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Create
Create operation.