I tried to use .Net binary serialization and my program raised the
following exception (in french) :
System.Runtime.Serialization.SerializationException: Le type
'Rhino.Mocks.Impl.RhinoInterceptor' dans l'assembly 'Rhino.Mocks,
Version=2.9.1.10183, Culture=neutral, PublicKeyToken=0b3305902db7183f'
n'est pas marqué comme sérialisable
It seems that 'Rhino.Mocks.Impl.RhinoInterceptor' isn't serializable.
Do you have any idea on how I can overcome this problem ?
A similar problem arises when I try to use a JSON serializer
(Newtonsoft.Json). Here the program raises the following exception :
Newtonsoft.Json.JsonSerializationException: Self referencing loop
It seems that there's a loop in objects references (maybe between the
dynamic proxy and the proxied object). Can you confirm that point ?
Anyway, thanks for your work, it's really a helpful tool !
Best regards,
Olivier
I tried to put [Serializable] on the interceptor and finally ended up
putting [Serializable] on half the project's class.
Once finished, I had no problem using .Net binary serialisation.
But it did not solve my XML serialization or JSon serialization issues.
I still have the same problem with JSon serializer and I get the
following error with XML serializer :
"System.InvalidOperationException: Impossible de sérialiser
CProxyTypeNServMon_CommonCollectionOccurrenceCommon_Rhino_Mocks_InterfacesIMockedObject_System_Runtime_SerializationISerializable2,
car il n'a pas de constructeur sans paramètres" which can be
translated to "no defaut (parameterless) constructor".
I guess I'll stick with actual limitations and not use mock objects
with serialization.
Best regards,
Olivier
> > Version= 2.9.1.10183, Culture=neutral, PublicKeyToken=0b3305902db7183f'
Thanks for your answers.
Ayende, I serialize mocks objects when I write a unit test for my "File
Store" class. This class basically writes the serialized state of a
set of business objects (binary serialization, XML serialization and
JSon serialization). To test my "FileStore.Store()" method, I choosed
to use a mocked business object. I'm not sure if it is a good idea
anyway.
Jeff, I'm not sure that [XmlIgnore] will help in my case since once of
the problem is the lack of parameterless constructor in mock objects. I
think [XmlIgnore] will help with circular references problem.
As i'm not inclined to modify deeply a framework that I don't control,
I prefer forget about serialization of my mock objets. Especially when
it's not an unavoidable feature.
Best regards,
Olivier
> -----Original Message-----
> From: Rhino...@googlegroups.com [mailto:Rhino...@googlegroups.com]
> On Behalf Of OAbrivard
> Sent: Wednesday, September 27, 2006 10:49 AM
> To: Rhino.Mocks
> Subject: Re: Using Serialization with Mock Objects
>
>
Is there a way to set that a certain call is not expected (using Dynamic ofcourse)?
Best regards.