You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
There are no changes at all to the petshop.business project, all the changes
required are in the petshop.data 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 code.google.com by alancjoh...@gmail.com on 22 Jun 2010 at 1:14
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.
Original comment by bniemyjski on 8 Jul 2010 at 9:34