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)); }
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)); }
private IEnumerable <byte> CommandHandler(IEnumerable <byte> received) { SafeExecution.TryCatch(() => CommandHandlerInternal(received), exception => _recorder.DefaultException(this, exception)); return(Enumerable.Empty <byte>()); }
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()); }
public void ExecuteCommand_WhenCalledForConnectWithWrongParameters_ShouldRecordError() { _sut.ExecuteCommand("connect"); Mock.Assert(() => _recorder.DefaultException(Arg.IsAny <object>(), Arg.IsAny <Exception>()), Occurs.Once()); }
public void ActivateAndSendCache() { SafeExecution.TryCatch(() => ActivateAndSendCacheInternal(), exception => _recorder.DefaultException(this, exception)); }
private Task <bool> TextEnteredHandler(string value) { return(SafeExecution.TryCatchWithResultAsync(() => _autoLocalConnector.ExecuteCommand(value), exception => _recorder.DefaultException(this, exception)));; }
private void StartProducing() { SafeExecution.TryCatchAsync(() => StartProducingInternal(), exception => _recorder.DefaultException(this, exception)); }
public void RegisterWrongCommandHandler(Action action) { SafeExecution.TryCatch(() => _remoteApiMap.RegisterWrongCommandHandler(action), exception => _recorder.DefaultException(this, exception)); }