示例#1
0
        public void Constructor_WhenCalled_ShouldRegisterTraceCommand()
        {
            _sut = new TraceableRemoteApiMap(_remoteApiMap, _remoteRecordsSender, _recorder);

            Mock.Assert(() => _remoteApiMap.RegisterCommand(RemoteApiCommands.TRACE, Arg.IsAny <Action>(), Arg.AnyString),
                        Occurs.Exactly(1));
        }
示例#2
0
        public TraceableRemoteApiMapWrapperRealSockets(IReadOnlyList <SocketTesterWrapper> sockets, ITraceableRemoteApiMap apiMap, ApplicationCacheRecorder recorder)
        {
            Sockets        = sockets;
            ApiMap         = apiMap;
            Recorder       = recorder;
            _connectedTask = new TaskCompletionSource <bool>();

            SocketAcceptedHandler = SocketAccepted;
        }
示例#3
0
        public void RegisterCommand_WhenThrows_ShouldCatch()
        {
            Mock.Arrange(() => _remoteApiMap.RegisterCommand("action", Arg.IsAny <Action>(), string.Empty)).Throws <Exception>();
            _sut = new TraceableRemoteApiMap(_remoteApiMap, _remoteRecordsSender, _recorder);
            Action a = () => { };

            _sut.RegisterCommand("action", a, string.Empty);

            Mock.Assert(() => _recorder.DefaultException(Arg.IsAny <Object>(), Arg.IsAny <Exception>()), Occurs.Exactly(1));
        }
示例#4
0
        public void TraceCommand_WhenCalled_ShouldActivateAndSendCache()
        {
            var remoteApiMap = new RemoteApiMapMock();

            _sut = new TraceableRemoteApiMap(remoteApiMap, _remoteRecordsSender, _recorder);

            remoteApiMap.TriggerTraceCommand();

            Mock.Assert(() => _remoteRecordsSender.ActivateAndSendCache(),
                        Occurs.Exactly(1));
        }
示例#5
0
        public void RegisterCommandWithParameters_WhenCalled_ShouldRegisterCommandWithParameters()
        {
            _sut = new TraceableRemoteApiMap(_remoteApiMap, _remoteRecordsSender, _recorder);

            Action <IEnumerable <string> > a = arr => { };

            _sut.RegisterCommandWithParameters("action", a, string.Empty);

            Mock.Assert(() => _remoteApiMap.RegisterCommandWithParameters("action", a, string.Empty),
                        Occurs.Exactly(1));
        }
示例#6
0
        public void RegisterCommand_WhenCalled_ShouldRegisterCommand()
        {
            _sut = new TraceableRemoteApiMap(_remoteApiMap, _remoteRecordsSender, _recorder);

            Action a = () => { };

            _sut.RegisterCommand("action", a, string.Empty);

            Mock.Assert(() => _remoteApiMap.RegisterCommand("action", a, string.Empty),
                        Occurs.Exactly(1));
        }
示例#7
0
        public void RegisterWrongCommand_WhenCalled_ShouldRegisterWrongCommand()
        {
            _sut = new TraceableRemoteApiMap(_remoteApiMap, _remoteRecordsSender, _recorder);

            Action a = () => { };

            _sut.RegisterWrongCommandHandler(a);

            Mock.Assert(() => _remoteApiMap.RegisterWrongCommandHandler(a),
                        Occurs.Exactly(1));
        }
示例#8
0
        public ApiOperator(
            IMonitoredRemoteOperator monitoredRemoteOperator,
            ITraceableRemoteApiMap traceableRemoteApiMap,
            IApplicationRecorder applicationRecorder)
        {
            _traceableRemoteApiMap   = traceableRemoteApiMap;
            _monitoredRemoteOperator = monitoredRemoteOperator;
            _applicationRecorder     = applicationRecorder;

            _traceableRemoteApiMap.RegisterWrongCommandHandler(WrongCommandHandler);
            _monitoredRemoteOperator.Start();
        }
示例#9
0
            public TraceableRemoteApiMapWrapper(Dictionary <string, SocketTester> sockets, ITraceableRemoteApiMap apiMap, ApplicationCacheRecorder recorder)
            {
                Sockets        = sockets;
                ApiMap         = apiMap;
                Recorder       = recorder;
                _connectedTask = new TaskCompletionSource <bool>();

                if (Sockets.TryGetValue("accepted", out SocketTester socket))
                {
                    socket.Byte49ReceivedFirstTime += SocketOnByte49ReceivedFirstTime;
                }
            }
示例#10
0
        private static IRunnable SetupCoreHandler(ITraceableRemoteApiMap map, IApplicationRecorder recorder)
        {
            recorder.RecordReceived += s => Console.WriteLine(s);

            // Create core logic here
            var core = new UsefulLogic(recorder);

            // Register commands here
            map.RegisterCommandWithParameters("set", parameter =>
            {
                core.SetValue(Int32.Parse(parameter.FirstOrDefault()));
            });

            return(core);
        }