/// <summary>
        /// Process synchronous messages through the sink chain. Mocking can be applied here.
        /// </summary>
        public IMessage SyncProcessMessage(IMessage msg)
        {
            IMethodCallMessage   mcm = (IMethodCallMessage)msg;
            IMethodReturnMessage result;

            if (RecorderManager.IsPlaying && RemotingMockService.IsUriToMock(mcm.Uri))
            {
                MockingProxy proxy = new MockingProxy(Type.GetType(mcm.TypeName), new RemotingPlayBackMocker(), mcm.Uri);
                result = (IMethodReturnMessage)proxy.Invoke(msg);
            }
            else if (RecorderManager.IsRecording && !RecorderManager.IsInCall && RemotingMockService.IsUriToMock(mcm.Uri))
            {
                MockingProxy proxy = new MockingProxy(Type.GetType(mcm.TypeName), null, mcm.Uri);
                MockableCall call  = new MockableCall(proxy, mcm);
                using (new RecorderManager.Lock()) {
                    result = SyncProcessMessageOnServer(mcm);
                    call.SetResult(result);
                    RecorderManager.RecordCall(call);
                }
            }
            else
            {
                result = (IMethodReturnMessage)nextMessageSink.SyncProcessMessage(msg);
            }
            return(result);
        }
예제 #2
0
 public void RecordingTest()
 {
     Support.RecorderListener listener = new Support.RecorderListener();
     RecorderManager.BeginRecording("test");
     using (new RecorderManager.Lock())
     {
         RecorderManager.RecordCall(null);
     }
     using (new RecorderManager.Lock())
     {
         RecorderManager.RecordCall(null);
     }
     RecorderManager.EndRecording();
     Assert.AreEqual(1, listener.BeginRecordingCounter);
     Assert.AreEqual(1, listener.EndRecordingCounter);
     Assert.AreEqual(2, CurrentRecorder.Count);
 }
 /// <summary>
 /// Process asynchronous messages through the sink chain. Mocking can be applied here.
 /// </summary>
 public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
 {
     if (RecorderManager.IsPlaying)
     {
         MockableCall     call    = new MockableCall(null, (IMethodCallMessage)msg);
         AsyncCallHandler handler = new AsyncCallHandler(replySink, call);
         RecorderManager.RecordCall(call);
     }
     else if (RecorderManager.IsRecording)
     {
     }
     else
     {
         return(NextSink.AsyncProcessMessage(msg, replySink));
     }
     return(nextMessageSink.AsyncProcessMessage(
                msg,
                new AsyncCallHandler(
                    replySink,
                    new MockableCall(null, (IMethodCallMessage)msg)
                    )
                ));
 }
예제 #4
0
 public void RecordingNeedsLockTest()
 {
     RecorderManager.BeginRecording("test");
     RecorderManager.RecordCall(null);
     RecorderManager.EndRecording();
 }