Model View Presenter, ObjectContainerDataSource and ECO

by john 2/10/2008 8:14:00 AM

I have recently been following the model view presenter pattern when developing web applications. The DataSource components found in ASP.Net won't work, so I began using ObjectContainerDataSource found in the Web Client Software Factory.

I particularly like ECO, a model powered framework for dotnet. I have therefore been investigating using ECO as the model with ObjectContainerDataSource. The datasource component requires that domain objects in the model have a parameterless constructor which I don't believe fits too well with ECO.

I have extended ObjectContainerDataSource by adding events which allow the model to construct the domain objects. 

I figured others might like the results of my investigation so I have placed the the sample code in CodeCentral.

The example is composed of a package with the extended ObjectContainerDataSource component and an ECO powered ASP.Net web application. Persistence is provided by Blackfish.

The web application is composed of 2 webpages.

 AllEmployees.aspx displays a list of employees as can be seen below. Two hyperlinks are available for inserting and editing the selected employee.


The second webform is for inserting, editing and deleting employees.


Common to each aspx is a Presenter class that handles the interaction between the webform and the model. Thats AllEmployeesPresenter and EmployeePresenter.

Each webform implements an interface through which the presenter moves domain objects back and forth to the model. There is a single model class used by both presenter classes. The model uses ECO as the data access layer.

 One of the primary reasons to use the MVP pattern is that it makes testing easy. I have a unit for each aspx file  that contains unit tests.

The picture below shows ECOMvPWebApplication.dll loaded in NUnit.


The tests are exercising the presenter objects. Presenter objects access the user interface through a interface. Objects implementing the interface are passed into the constructor of each presenter.

Each of the WebForms implement the appropriate interface  IAllEmployeeView or IEmployeeView. It would be quite difficult to pass in an actual instance of a webform so I've used NMock a mocking library to provide fake implementations of objects that implement the required interfaces.

The end result is that I can concentrate on directly testing my code. 


To run the webapplication you should just need to build the projectgroup. I have included the NUnit and NMock runtimes in the lib subdirectory. There is also a copy of the server control assembly from the Web Client software factory.

The sample uses ECO and Blackfish currently available in CodeGears Delphi 2007.

The Blackfish database is in the WebApplications App_Data. You will probably need to modify the database connection string in PersistanceMapperProvider.pas, currently its


Self.dataStoreConnection1.ConnectionString := 'host=LocalHost;database=c:\' +  'develop\moshine\ExtendedObjectContainerDataSource\EcoMVPWebApplication\App_Data\EcoWebApplication6.js;user=' +


In my opinion the following are true:- 

Developing database centric web applications is alot easier and faster using Eco.

Using the MVP pattern makes it easier to test and well tested code is important.

The code for this sample can be found here in CodeCentral

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


TDD | ECO | NUnit | Blackfish | ASP.Net 2.0 | CodeGear | NMock | MVP | Delphi

Related posts


2/12/2008 3:42:35 AM


Hi John
Thanks for writing this ECO Delphi article for MVP.Till now i have found all ECO gurus writing only C# articles for MVP with ECO..
While I could run every thing I was not able to test the Test application.How to load ECOMvPWebApplication.dll n NUnit.(i am able to compile the test application .But i get no teat cases in the treeview)


2/12/2008 6:15:59 AM


Your welcome.

What version of NUnit are you using ?

I'm using 2.4.3. In this version the GUI runner is called NUnit.exe and can be located in the NUnit bin directory.


2/12/2008 10:10:19 AM


I am using 2.4.6.I just ran the test application & i got only an empty GUI without any test cases.Do you have to separately load the EcoMVPApplication.dll


2/12/2008 9:18:46 PM


You run the nunit application, do open project from the menu and select ecomvpapplication.dll You can also pass the assembly name as a parameter to nunit so that you can run the tests from the IDE.


2/13/2008 2:00:11 PM


Where is the source for your unit tests?


2/13/2008 2:57:37 PM

Hi John

I'd be willing to share my ECO->MonoRail integration if you'd like to try that MVC approach to writing web apps? Smile

Peter Morris

2/13/2008 7:29:37 PM


There is no separate unit tests.They are all part of the main application.Once can just load the main dll into nUnit to test


2/13/2008 7:41:08 PM


Hi Peter,

Thanks for the offer, unfortunately I'm currently updating an existing application. Mind you I do learning stuff from your blog, the Inversion of Control post was really good.

The unit tests are part of the EcoMVPWebApplication project in
AllEmployeesTests.pas and EmployeeTests.pas


2/13/2008 8:38:20 PM


HI John
Is it possible for you to write a more detailed article (in spite of your busy schedule )about the whole thing to help out the Delphi ECO guys like me..While i have been able to run the tests now , where odes one start?
I feel you are the only delphi expert seriously perusing Delphi & ECO & hence I am asking you


2/14/2008 1:09:41 AM


This wikipedia article gives reasons as to why you want to do unit tests for your code

I think testing web applications can be quite difficult. The mvp pattern makes it easier because you can test more of the code.
Even a few tests is better than nothing.

What kind of things would you like in a more detailed article ?


2/14/2008 2:27:47 AM


Hi John
Thanks for asking

MVC Pattern-What,why & how.
MVC pattern with ECO & Delphi -How to write the test cases
ObjectDataSource-Why it requires to be extended?
Why Mock Objects are required ?
Finally you know best what a new comer to these topics require ?
Further I feel CO should hire you to do more indepth articles on ECO & Delphi since they are focussing on C# (forgetting that alienating their existing Delphi ECO customers is bad for their business)
Many people including Bob Swart have given up on ECO.May ne you can bring back more Delphi people to ECO


Comments are closed

Powered by BlogEngine.NET
Theme by Mads Kristensen

About the author

Name of author John Moshakis
I'm a software developer living in Toronto..

E-mail me Send mail


<<  May 2022  >>

View posts in large calendar


    Recent posts

    Recent comments



    Don't show


      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      © Copyright 2022

      Sign in