Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement of CSLA templates to allow Mockable DataAccess Layer #426

GoogleCodeExporter opened this issue Aug 3, 2015 · 8 comments


Copy link

I have only converted the fetch method on the Order Business Object to use a 
mock DAL. I have converted more objects in our own code but I am unable to send 
that out, so I would have to do more of the petshop application if you want to 
see more.

I think the best way to include this in the current templates would be to add 
another option to the list of Data Access Implementations called 
ObjectFactoryStoredProceduresWithDtos. If you don’t like adding Unity as a 
dependency in this situation I would still see a lot of value in just making it 
so the Object factory uses a hard coded DAL object which returns a DTO. The 
hard work is in creating all the DTOs and DALs which are really just 
boilerplate code. In fact the DALs are almost exactly what you have in the 
object factories at the moment. By adding this extra abstraction though you 
allow for mocking as you can see by the test I have written. It also follows 
the Single Responsibility pattern by making the object factory just a factory 
not a DAL as well.

These are the changes I have made to the solution I downloaded from the 
codesmith site:

There are no changes at all to the project, all the changes 
required are in the project.
Add UnitySingleton Class
Add reference to Micosoft.Practices.Unity
Create a DTO per entity
Create a Dao per entity
Create a Dao Interface per Entity
Add one line to the top of every factory class to create a dao and resolve its 
type from the unity Singleton.
Modify the map helper method to take a dto
I have removed the Web UI and Test Project
I have created another test project which uses rhino mocks and Nunit to show 
how I use a mock to insulate the test from any real external DB.

Original issue reported on by on 22 Jun 2010 at 1:14


Copy link

Original comment by bniemyjski on 22 Jun 2010 at 2:02

  • Changed state: Investigating
  • Added labels: Framework-CSLA, Type-Enhancement

Copy link


I took a look into this, I like how this is implemented, but I think if you are 
not using Object Factory than you are left out in the dark :s.

I think that a lot of code could be reduced by making the IObjectDao into a 
generic interface like IStore<DTO>. I'd really like to get rid of a dto object, 
but if it is only present in the data project than I can live with that :).

I think that I would move the Interfaces to an \Inteface folder, move the dto's 
to reside under the ObjectFactory classes and make them use merge regions.

I don't think it would take very much to generate this. Would you be interested 
in updating the templates? I'd add a new generation option for unit tests.

-Blake Niemyjski

Original comment by bniemyjski on 8 Jul 2010 at 9:34

  • Changed state: UnderConsideration

Copy link

Original comment by bniemyjski on 15 Jul 2010 at 3:48

  • Changed state: Accepted

Copy link


Mock data would make a great topic for some blog posts. I would love to see how 
folks are unit testing there CSLA objects. I wonder if alancjohnson, might be 
posting anyway about this.

Original comment by on 15 Jul 2010 at 9:38

Copy link


Original comment by on 28 Oct 2011 at 12:03

Copy link

I'd like to see this happen as well :)

Original comment by bniemyjski on 1 Nov 2011 at 3:43

Copy link

[deleted comment]

Copy link

Original comment by bniemyjski on 9 Mar 2012 at 1:10

  • Changed state: UnderConsideration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants