Vibrant discussion about CSLA .NET and using the framework to build great business applications.
We really want to be able to test our business objects without hitting a database ... so I spent some time with the CSLA book and watched the 3.8 Core videos and so this concept of using the business object to invoke the DAL. I saw in the demo where Rocky is loading from an ADO DAL and a MOCK DAL. This looks like just what we need!
A couple of changes we are going to make is actually have something like ICustomerFactory and ICustomer, so we can pass a Customer business object that implements ICustomer to the ICustomerFactory ... this way we don't need to pass in a ton of parameters. I'm curious if this makes sense and if other have a better way.
The other thing, is that with the Mock DAL we would like to "fill" it with different data at different times ... mainly for different test scenarios. I noticed in Rocky's Mock DAL he is prepopulating it with data. I would like to do this dynamically ... or even something like an in memory database? Again, I just need the data to be tweaked for each different test scenario. Is anyone else trying to do this ... and if so, I'd appreciate any help you could provide!
My misunderstanding, I thought you were thinking of the ObjectFactory implementation in Csla.
The cslacontrib also has a sample shows a Repository pattern following your line of thinking. Have a look at the MEF Repository sample.
Have a look at my blog post too: http://jonnybekkum.wordpress.com/2010/12/30/cslacontrib-mef-and-repository-pattern-with-csla4/
Jonny Bekkum, Norway
You could change access to the injected property to private. MEF can inject into public, internal and private properties.
If you wish to keep the property public and hidden in designers/intellisense that use your assembly you could add the EditorBrowsableAttribute to the property:
[EditorBrowsable(EditorBrowsableState.Never)]For more info on this attribute: http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx
I am working through this now in my test class and am now receiving the following error:
Type 'CslaContrib.MEF.MefBusinessBase`1[[CompanyName.ProjectName.Business.Customer, CompanyName.ProjectName.Business, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null]]' in Assembly 'CslaContrib.MEF, Version=220.127.116.11, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Is it as simple to mark the MefBusinessBase as Serializable or this masking some other problem?
Added the [Serializable] Attribute to the MEF objects and everything seems to work ... tests pass ... confirming right now.
Cant believe i missed the [Serializable] attribute.
I have added [Serializable] to all base classes in CslaContrib and correct ones are available for download now.
Thanks again Jonny!