Hi Ayende,
My Serializable Class:
[System.SerializableAttribute()]
public class MyOwnClass
{
public delegate bool MyOwnDelegate(object msg, int result);
public bool MyFunction(object msg, int result)
{
RequestResponseRequest msgToSend = msg as
RequestResponseRequest;
if (msgToSend != null)
{
return ((msgToSend.Header.resultCode == result));
}
else
{
return false;
}
}
}
My test method:
[TestMethod]
public void TestMethod1()
{
MyOwnClass mineClass = new MyOwnClass();
IHeaderType req = new IHeaderType()
{
resultCode = 0,
CodeReturn = 0,
};
RequestResponseRequest reqRequest = new
RequestResponseRequest(req);
#if(MY_STUB)
{
IHeaderType respMine = new IHeaderType()
{
resultCode = 1,
CodeReturn = 1,
};
MyOwnClass.MyOwnDelegate myDelHere = new
MyOwnClass.MyOwnDelegate(mineClass.MyFunction);
//Predicate<bool> myConstraint = (delegate { return myDelHere
(reqRequest, req.resultCode); });
Predicate<bool> myConstraint = (delegate { return
mineClass.MyFunction(reqRequest,req.resultCode); });
RequestResponseResponse respRequest = new
RequestResponseResponse(respMine);
mockService.RequestResponse(reqRequest);
simControl.LastCall<RequestResponseResponse>().Return
(respRequest).Constraints(Is.Matching<bool>(myConstraint));
simControl.MockRepositoryControl.ReplayAll();
}
#endif
req.resultCode = 10;
var resp = realService.RequestResponse(reqRequest);
Assert.IsTrue(resp.IHeader.resultCode == 1);
simControl.MockRepositoryControl.VerifyAll
();
}
Once again I am sorry, I could not abe to upload a simple file. Every
file .cs or .txt, any file, it is giving security warning.
Here my aim is, I initialized one variable with 0. In Record mode, I
am calling a delegate. In playback mode i am changing the variable
value from 0 to 10. So my intention is that, with the delegate and
is.matching(), the result code should be updated to 10 and it should
pass.
This scenario is working for me in a normal project. But with
remoting, I am getting this serializable problem.
Regards,
Raju.
Regards,
Raju.