i want to create unit test project using MSTest that use Mock object.and also using dataportal.
could you please assets me. and give us simple example how can i do it.
http://windingroadway.blogspot.com/2013/12/csla-inversion-of-control-and-unit.html
http://magenic.com/BlogArchive/AbstractionsinCSLA
In addition to Rocky's post, I've found utilizing a SL patter in the DP methods of your business objects to be helpful. You can then get an interface to your DAL or web server or whatever to do the data access and mock it. In practice this means the only impact in the unit test is that you configure the SL interface to return your mocks instead of doing constructor injection into the Csla object, and except for the SL interface you don't have any more dependencies than you did before, you're just changing how Csla objects get their dependencies. From a normal use (such as from your UI) your UI doesn't need to know what the Csla object needs to do its job which I think is actually preferable (DB vs WS is an implementation detail the UI should not even know about).
As far as the data portal goes, I'd treat that just like .Net framework code; its not worth mocking and we should assume Csla works correctly, just as we assume System.String works correctly. So your unit tests can cause the Csla data portal code to run and it should not concern you any more than calling string.Format. You do want to do things like get, new and save though as your DP_XYZ methods need testing and of course must have the correct signature.
Copyright (c) Marimer LLC