----------------------------------------------- using System; using System.Data; using OakLeaf.MM.Main; using OakLeaf.MM.Main.Patterns; using OakLeaf.MM.Main.Managers; using OakLeaf.MM.Main.Data; //using OakLeaf.MM.Main.Windows.Forms; //using OakLeaf.MM.NorthwindSample.Main.Windows.Forms; using Acme.OrderSystem.Business; namespace mmApplication { /// <summary> /// Main application entry class /// </summary> class AppMainEntry : mmMainEntry { /// <summary> /// Static field that contains a reference to the application object /// </summary> public static mmApplication.AppBase App; /// <summary> /// Main application entry point /// </summary> public static void Main() { try { // Instantiate the Application Object App = new AppBase(); // Instantiate the Order Acme.OrderSystem.Business.Orders orders = new Acme.OrderSystem.Business.Orders(); // Get a dataset mmDataSet ds; ds = orders.GetAllOrders(); // Instantiate the main application form // Application.Run(new MainForm()); } catch (Exception e) { // Write the error to the application log mmAppBase.Log.WriteException(e); // Display the Exception form //mmExceptionForm ExceptForm = new mmExceptionForm(e.Message, e.StackTrace); //ExceptForm.ShowDialog(); } finally { } } } } ----------------------------------------2. Orders.cs
using System; using System.Data; using System.Xml; using OakLeaf.MM.Main; using OakLeaf.MM.Main.Patterns; using OakLeaf.MM.Main.Managers; using OakLeaf.MM.Main.Business; using OakLeaf.MM.Main.Data; using NUnit.Framework; //using mmApplication; namespace Acme.OrderSystem.Business { /// <summary> /// Summary description for Orders. /// </summary> public class Orders : ABusinessObject { public Orders() { this.TableName = "Orders"; this.PrimaryKey = "OrderID"; } public DataSet GetOrdersByCustomerID(string customerID) { return this.GetDataSet("SELECT * From Orders WHERE CustomerID = '" + customerID + "'"); } public DataSet GetOrderByOrderID(int orderID) { return this.GetDataSet("SELECT * FROM Orders WHERE OrderID = " + orderID); } public mmDataSet GetAllOrders() { DataSet ds = new DataSet(); return (mmDataSet) this.GetDataSet("Select * from Orders"); } } [TestFixture] public class TestOrders { public Orders orders; public mmAppBase app; [TestFixtureSetUp] public void Setup() { this.app = new mmAppBase(); this.orders = new Orders(); } [Test] public void IsAppRunning() { Assert.IsTrue( mmAppBase.IsRunning ); } [Test] public void TestTableName() { Assert.AreEqual( "Orders", orders.TableName ); } [Test] public void TestDataSet() { DataSet ds = orders.GetAllOrders(); Assert.AreEqual(false, ds.HasChanges() ); } [Test] public void TestGetAllOrders() { DataSet ds = orders.GetAllOrders(); Assert.AreEqual(ds.Tables["Orders"].Rows.Count, 0 ); } } }