public void HandleRequest(string[] args, IDivLogger divLogger) { _logger = divLogger; try { //Chain of responsibility pattern RemoveHandler removeHandler = new RemoveHandler(new GeneralFileRemover()); CopyHandler copyHandler = new CopyHandler(); HelpHandler helpHandler = new HelpHandler(); removeHandler.Successor = copyHandler; copyHandler.Successor = helpHandler; removeHandler.HandleRequest(args, _logger); } catch (CommandLineEntryException exception) { _logger.Log(exception.Message, LogSeverity.High); _logger.Log(CommandLineUsage.Usage, LogSeverity.Low); } catch (Exception exception) { _logger.Log(exception.Message, LogSeverity.Highest); } }
public override void Context() { base.Context(); _fileRemoverMock.Setup( fileRemover => fileRemover.RemoveFileByName(It.IsAny<string>(), It.IsAny<string[]>())) .AtMostOnce(); RemoveHandler = new RemoveHandler(_fileRemoverMock.Object); RemoveHandler.HandleRequest(new[] { "--remove", "-n", "rootpath", "file2.txt file2.txt" }, _divLoggerMock.Object); }
public override void Context() { base.Context(); _fileRemoverMock.Setup( fileRemover => fileRemover.RemoveByRegularExpression(It.IsAny<string>(), It.IsAny<string>())) .AtMostOnce(); RemoveHandler = new RemoveHandler(_fileRemoverMock.Object); RemoveHandler.HandleRequest(new[] { "--remove", "-rx", "rootpath", "[A-Z][a-z]" }, _divLoggerMock.Object); }