CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Silverlight DAL selection IObjectFactoryLoader??

rated by 0 users
Not Answered This post has 0 verified answers | 2 Replies | 1 Follower

Top 500 Contributor
27 Posts
csmith1 posted on Tue, Apr 3 2012 10:34 AM

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. 


All Replies

Top 500 Contributor
27 Posts

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.

 

Top 500 Contributor
27 Posts

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.

Page 1 of 1 (3 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems