Open vsinghal7 opened 7 years ago
Perhaps @JasonBock can provide some insight, as he's done quite a bit of mocking against CSLA types.
I think the key though, is that you can't actually call the data portal. Instead you need to provide your own implementation of IDataPortal that doesn't actually do any work - thus providing a safe mock of the data portal itself.
You need to set CSLA such that it doesn't serialize objects in your unit tests when you use frameworks like Moq. In the <appSettings>
section of your .config file, add this:
<add key="CslaAutoCloneOnUpdate" value="false" />
I am trying to Moq with csla for unit testing. Moq is working fine with mocking fetch calls but not working with mocking save call of editable business List base.
I am creating the object of BusinessListBase class using DataPortal.Create method and then I add a mock object of child class(businessbase) to the object of list base class.
var listObject = DataPortal.Create();
listObject.Add(testMock.Object);
When I try to call the DataPortal_Update method of my BusinessListBase class (DataPortal.Update(listObject)), it gives me this piece of error - "Type 'Moq.Proxy.ProxyMethodHook' in Assembly 'Moq, Version=4.2.1502.911, Culture=neutral, PublicKeyToken=69f491c39445e920' is not marked as serializable."
I have setup all the necessary setups of mock object like IsDirty, IsValid etc.
I am completely stuck here, Please provide inputs on this.
Thanks in advance!!!! Vinod