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.
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.
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