コード例 #1
0
        public void SendInstruction_WhenCalledWithoutSession_ShouldThrow()
        {
            var task = _sut.SendInstruction(Enumerable.Empty <byte>());

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Mock.Assert(() => _recorder.DefaultException(
                            Arg.IsAny <Object>(),
                            Arg.IsAny <Exception>()), Occurs.Exactly(1));
        }
コード例 #2
0
        public void ExecuteCommand_WhenThrows_ShouldCatch()
        {
            Mock.Arrange(() => _autoLocalConnector.ExecuteCommand(Arg.AnyString)).Throws <Exception>();
            _sut = new MonitoredRemoteOperator(_autoLocalConnector, _remoteTraceMonitor, _recorder);

            Mock.Raise(() => _remoteTraceMonitor.CommandReceived += null, "text");

            Mock.Assert(() => _recorder.DefaultException(Arg.IsAny <Object>(), Arg.IsAny <Exception>()), Occurs.Exactly(1));
        }
コード例 #3
0
        private IEnumerable <byte> CommandHandler(IEnumerable <byte> received)
        {
            SafeExecution.TryCatch(() => CommandHandlerInternal(received),
                                   exception => _recorder.DefaultException(this, exception));

            return(Enumerable.Empty <byte>());
        }
コード例 #4
0
        public async void OperatorConstructor_WhenCalled_ShouldCallReceiveInAcceptedSocket()
        {
            var socketTester1 = new SocketTester("connector");
            var socketTester2 = new SocketTester("listener");
            var socketTester3 = new SocketTester("accepted");
            var socketFactory = ArrangeSocketFactoryLocal(socketTester1, socketTester2, socketTester3);

            var remoteTraceMonitorСonsistent = new RemoteTraceMonitorСonsistentTester(null);

            CreateLocalOperator(socketFactory, _cacheRecorder, remoteTraceMonitorСonsistent);

            await remoteTraceMonitorСonsistent.Initialized;

            _output.WriteLine("Errors:");
            _output.WriteLine(_cacheRecorder.ErrorCache);
            _output.WriteLine("Info:");
            _output.WriteLine(_cacheRecorder.InfoCache);
            Assert.Equal(3, socketTester3.ReceiveCalledTimes);
            Mock.Assert(() => _recorder.DefaultException(Arg.IsAny <Object>(), Arg.IsAny <Exception>()),
                        Occurs.Never());
            Mock.Assert(() => _recorder.RecordError(Arg.IsAny <string>(), Arg.IsAny <string>()),
                        Occurs.Never());
        }
コード例 #5
0
        public void ExecuteCommand_WhenCalledForConnectWithWrongParameters_ShouldRecordError()
        {
            _sut.ExecuteCommand("connect");

            Mock.Assert(() => _recorder.DefaultException(Arg.IsAny <object>(), Arg.IsAny <Exception>()), Occurs.Once());
        }
コード例 #6
0
 public void ActivateAndSendCache()
 {
     SafeExecution.TryCatch(() => ActivateAndSendCacheInternal(),
                            exception => _recorder.DefaultException(this, exception));
 }
コード例 #7
0
 private Task <bool> TextEnteredHandler(string value)
 {
     return(SafeExecution.TryCatchWithResultAsync(() => _autoLocalConnector.ExecuteCommand(value),
                                                  exception => _recorder.DefaultException(this, exception)));;
 }
コード例 #8
0
 private void StartProducing()
 {
     SafeExecution.TryCatchAsync(() => StartProducingInternal(),
                                 exception => _recorder.DefaultException(this, exception));
 }
コード例 #9
0
 public void RegisterWrongCommandHandler(Action action)
 {
     SafeExecution.TryCatch(() => _remoteApiMap.RegisterWrongCommandHandler(action),
                            exception => _recorder.DefaultException(this, exception));
 }