Silverlight DAL selection IObjectFactoryLoader??

Silverlight DAL selection IObjectFactoryLoader??

Old forum URL:

csmith1 posted on Tuesday, April 03, 2012

For Silverlight unit testing I am thinking I would like to compile my Mock DAL and object factories in Silverlight.

I do not see how to implement an Csla.Server.IObjectFactoryLoader in Silverlight.

The alternative would be to generate factory name that link to my Silverlight Mock DAL.

I'd like to be able to unit test Silverlight viewmodels and model. 

csmith1 replied on Tuesday, April 03, 2012

So I used some compiler option to get the MOCK DAL to to be referenced . I can see the fetch calls are getting to the factory but the FetchCompleted is not firing. So I can not test async functions.


csmith1 replied on Tuesday, April 03, 2012

I made this change to CSLA.Silverlight4.DataPortalClient.FactoryProxy.

 public void BeginFetch(object criteria, object userState)
      _userState = userState;
      var obj = Activator.CreateInstance(Csla.Reflection.MethodCaller.GetType(_attribute.FactoryTypeName));
      var handler = new CompletedHandler(OnFetchCompleted);
     var result =  MethodCaller.CallMethod(obj, _attribute.FetchMethodName, criteria, handler);
     if (result != null)
         handler((T)result, null);
Looks like this should wrapped in a try catch as well to throw the error to the OnFetchCompleted
 event as well.
It would be nice if someone could confirm this is a good fix. It pass my test now. Calling the Mock DB DAL and a real DB DAL.

Copyright (c) Marimer LLC