Beispiel #1
0
        static public void ProcessRemoteRequest(RemoteMachine machine, ReceiveCoreActionDelegate receive, CoreAction action)
        {
            ManualResetEvent         e         = new ManualResetEvent(false);
            RequestProcessedDelegate processed = (c, r, a) =>
            {
                if (c == machine.Core && (r == null || r == action))
                {
                    e.Set();
                }
            };

            machine.Core.Auditors += processed;

            receive(action);
            machine.Start();

            bool result = false;

            while (!result)
            {
                result = e.WaitOne(100);
                machine.AdvancePlayback(100000);
            }

            machine.Core.Auditors -= processed;

            machine.Stop();

            if (!result)
            {
                throw new TimeoutException("Timeout while waiting for request to process.");
            }
        }
Beispiel #2
0
        public void Setup()
        {
            _mockRemote  = new Mock <IRemote>();
            _mockAuditor = new Mock <MachineAuditorDelegate>();

            _receiveCoreAction = null;
            _mockRemote.SetupSet(r => r.ReceivePing = It.IsAny <ReceivePingDelegate>()).Callback <ReceivePingDelegate>(callback => _receivePing = callback);
            _mockRemote.SetupSet(r => r.ReceiveName = It.IsAny <ReceiveNameDelegate>()).Callback <ReceiveNameDelegate>(callback => _receiveName = callback);
            _mockRemote.SetupSet(r => r.ReceiveRequestAvailableMachines = It.IsAny <ReceiveRequestAvailableMachinesDelegate>()).Callback <ReceiveRequestAvailableMachinesDelegate>(callback => _receiveRequestAvailableMachines = callback);
            _mockRemote.SetupSet(r => r.ReceiveSelectMachine            = It.IsAny <ReceiveSelectMachineDelegate>()).Callback <ReceiveSelectMachineDelegate>(callback => _receiveSelectMachine = callback);
            _mockRemote.SetupSet(r => r.ReceiveCoreAction = It.IsAny <ReceiveCoreActionDelegate>()).Callback <ReceiveCoreActionDelegate>(callback => _receiveCoreAction = callback);
            _mockRemote.SetupSet(r => r.CloseConnection   = It.IsAny <CloseConnectionDelegate>()).Callback <CloseConnectionDelegate>(callback => _closeConnection = callback);
        }