CommandLineArgParser CreateSut() { var parser = new CommandLineArgParser(environment); parser.Parse(); return(parser); }
private static Config LoadAppConfig() { var commandLineArgParser = new CommandLineArgParser(Environment.GetCommandLineArgs()); var executionAssemblyDir = Assembly.GetExecutingAssembly().Location; var configPath = Path.Combine(Path.GetDirectoryName(executionAssemblyDir), $"Config\\{commandLineArgParser.Environment}\\config.json"); var config = new ConfigLoader(configPath).Load(); return config; }
public SearchBarViewModel(CommandLineArgParser commandLineArgParser, ISettingsProvider settingProvider) { this.commandLineArgParser = commandLineArgParser; this.settingProvider = settingProvider; SearchCommand = Command.CreateAsync(this, Search, vm => vm.CanSearch); CancelSearchCommand = Command.CreateAsync(this, CancelSearch, vm => vm.CanCancelSearch); }
public SearchBarViewModel(CommandLineArgParser commandLineArgParser, ISettingsProvider settingProvider) { this.commandLineArgParser = commandLineArgParser; this.settingProvider = settingProvider; PageSize = 50; //NOTE: Do we need to change this? SearchCommand = this.CreateCommand(Search, vm => vm.CanSearch); CancelSearchCommand = this.CreateCommand(CancelSearch, vm => vm.CanCancelSearch); }
public void CommandLineArgParserTest() { // 正常入力テスト var testCase = new string[] { "", "4", "5 -o -t 12:30", "--help", "hoge piyo meu -i input -o output", "-a ikorin 24 -b hoge --hoge --time 3:34 piyo", }; var answers = new CommandLineArgument[] { new CommandLineArgument(new string[0], new Dictionary <string, string>()), new CommandLineArgument(new [] { "4" }, new Dictionary <string, string>()), new CommandLineArgument(new [] { "5" }, new Dictionary <string, string>() { { "-o", "" }, { "-t", "12:30" } }), new CommandLineArgument(new string[0], new Dictionary <string, string>() { { "--help", "" } }), new CommandLineArgument(new [] { "hoge", "piyo", "meu" }, new Dictionary <string, string>() { { "-i", "input" }, { "-o", "output" } }), new CommandLineArgument(new [] { "24", "piyo", }, new Dictionary <string, string>() { { "-a", "ikorin" }, { "-b", "hoge" }, { "--hoge", "" }, { "--time", "3:34" } }), }; foreach (var(param, answer) in testCase.Zip(answers, (test, ans) => (test, ans))) { var args = param.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var parsed = CommandLineArgParser.Parse(args); Assert.True(parsed.Args.SequenceEqual(answer.Args)); Assert.True(parsed.OptionalArgs.SequenceEqual(answer.OptionalArgs)); } // エラー入力テスト var errorCase = new string?[] { null, "-o -o", }; var errors = new Action <Action>[] { action => Assert.Throws <ArgumentNullException>(action), action => Assert.Throws <ArgumentException>(action), }; foreach (var(param, assertError) in errorCase.Zip(errors, (test, err) => (test, err))) { var args = param?.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) !; assertError(() => CommandLineArgParser.Parse(args)); } }
public void CommandMessage(string args, Type commandType, string message) { LogioConfig config = GetTestConfig(); LogioTestClient client = new LogioTestClient(); var parser = new CommandLineArgParser(() => config, x => client); var command = parser.Parse(Helper.CommandLineToArgs(args)); Assert.NotNull(command); Assert.IsType(commandType, command); command.Execute(); Assert.Equal(message, client.Message); }
public EndpointExplorerViewModel( IEventAggregator eventAggregator, ISettingsProvider settingsProvider, ServiceControlConnectionProvider connectionProvider, CommandLineArgParser commandLineParser, IServiceControl serviceControl, NetworkOperations networkOperations) { this.eventAggregator = eventAggregator; this.settingsProvider = settingsProvider; this.serviceControl = serviceControl; this.networkOperations = networkOperations; this.connectionProvider = connectionProvider; this.commandLineParser = commandLineParser; Items = new BindableCollection <ExplorerItem>(); }
private LogioConfig RunAndReturnConfig(string args, Type commandType) { var config = GetTestConfig(); var client = new LogioTestClient(); var argsArray = Helper.CommandLineToArgs(args); var parser = new CommandLineArgParser(() => config, x => client); var command = parser.Parse(argsArray); Assert.NotNull(command); Assert.IsType(commandType, command); command.Execute(); return(config); }
public void TestInitialize() { windowManager = Substitute.For <WindowManagerEx>(); endpointExplorer = Substitute.For <EndpointExplorerViewModel>(); messageList = Substitute.For <MessageListViewModel>(); licenseStatusBar = Substitute.For <LicenseStatusBar>(); statusbarManager = new StatusBarManager(licenseStatusBar); eventAggregator = Substitute.For <IEventAggregator>(); workNotifier = Substitute.For <IWorkNotifier>(); messageFlow = Substitute.For <MessageFlowViewModel>(); sagaWindow = Substitute.For <SagaWindowViewModel>(); messageBodyView = Substitute.For <MessageBodyViewModel>(); messageProperties = Substitute.For <MessagePropertiesViewModel>(); view = Substitute.For <IShellViewStub>(); headerView = Substitute.For <MessageHeadersViewModel>(); sequenceDiagramView = Substitute.For <SequenceDiagramViewModel>(); settingsProvider = Substitute.For <ISettingsProvider>(); licenseManager = Substitute.For <AppLicenseManager>(); logWindow = Substitute.For <LogWindowViewModel>(); settingsProvider.GetSettings <ProfilerSettings>().Returns(DefaultAppSetting()); app = Substitute.For <IAppCommands>(); commandLineArgParser = MockEmptyStartupOptions(); shell = new ShellViewModel( app, windowManager, endpointExplorer, messageList, () => Substitute.For <ServiceControlConnectionViewModel>(), () => Substitute.For <LicenseMessageBoxViewModel>(), statusbarManager, eventAggregator, workNotifier, licenseManager, messageFlow, sagaWindow, messageBodyView, headerView, sequenceDiagramView, settingsProvider, messageProperties, logWindow, commandLineArgParser); ((IViewAware)shell).AttachView(view); }
public void TestInitialize() { WindowManager = Substitute.For <WindowManagerEx>(); EndpointExplorer = Substitute.For <EndpointExplorerViewModel>(); MessageList = Substitute.For <MessageListViewModel>(); StatusbarManager = Substitute.For <StatusBarManager>(); EventAggregator = Substitute.For <IEventAggregator>(); MessageFlow = Substitute.For <MessageFlowViewModel>(); SagaWindow = Substitute.For <SagaWindowViewModel>(); MessageBodyView = Substitute.For <MessageBodyViewModel>(); MessageProperties = Substitute.For <MessagePropertiesViewModel>(); View = Substitute.For <IShellViewStub>(); HeaderView = Substitute.For <MessageHeadersViewModel>(); SequenceDiagramView = Substitute.For <SequenceDiagramViewModel>(); SettingsProvider = Substitute.For <ISettingsProvider>(); LicenseManager = Substitute.For <AppLicenseManager>(); LogWindow = Substitute.For <LogWindowViewModel>(); SettingsProvider.GetSettings <ProfilerSettings>().Returns(DefaultAppSetting()); App = Substitute.For <IAppCommands>(); CommandLineArgParser = MockEmptyStartupOptions(); shell = new ShellViewModel( App, WindowManager, EndpointExplorer, MessageList, () => Substitute.For <ServiceControlConnectionViewModel>(), () => Substitute.For <LicenseRegistrationViewModel>(), StatusbarManager, EventAggregator, LicenseManager, MessageFlow, SagaWindow, MessageBodyView, HeaderView, SequenceDiagramView, SettingsProvider, MessageProperties, LogWindow, CommandLineArgParser); ((IViewAware)shell).AttachView(View); }
public ShellViewModel( IAppCommands appCommander, IWindowManagerEx windowManager, EndpointExplorerViewModel endpointExplorer, MessageListViewModel messages, Func <ServiceControlConnectionViewModel> serviceControlConnection, Func <LicenseRegistrationViewModel> licenceRegistration, StatusBarManager statusBarManager, IEventAggregator eventAggregator, AppLicenseManager licenseManager, MessageFlowViewModel messageFlow, SagaWindowViewModel sagaWindow, MessageBodyViewModel messageBodyViewer, MessageHeadersViewModel messageHeadersViewer, SequenceDiagramViewModel sequenceDiagramViewer, ISettingsProvider settingsProvider, MessagePropertiesViewModel messageProperties, LogWindowViewModel logWindow, CommandLineArgParser comandLineArgParser) { this.appCommander = appCommander; this.windowManager = windowManager; this.eventAggregator = eventAggregator; this.licenseManager = licenseManager; this.settingsProvider = settingsProvider; this.comandLineArgParser = comandLineArgParser; this.serviceControlConnection = serviceControlConnection; this.licenceRegistration = licenceRegistration; MessageProperties = messageProperties; MessageFlow = messageFlow; SagaWindow = sagaWindow; StatusBarManager = statusBarManager; EndpointExplorer = endpointExplorer; MessageHeaders = messageHeadersViewer; MessageBody = messageBodyViewer; SequenceDiagram = sequenceDiagramViewer; Messages = messages; LogWindow = logWindow; Items.Add(endpointExplorer); Items.Add(messages); Items.Add(messageHeadersViewer); Items.Add(messageBodyViewer); Items.Add(messageFlow); InitializeAutoRefreshTimer(); InitializeIdleTimer(); ShutDownCommand = this.CreateCommand(() => this.appCommander.ShutdownImmediately()); AboutCommand = this.CreateCommand(() => this.windowManager.ShowDialog <AboutViewModel>()); HelpCommand = this.CreateCommand(() => Process.Start(@"http://docs.particular.net/")); ConnectToServiceControlCommand = this.CreateCommand(ConnectToServiceControl, vm => vm.CanConnectToServiceControl); RefreshAllCommand = this.CreateCommand(RefreshAll); RegisterCommand = this.CreateCommand(() => { this.windowManager.ShowDialog <LicenseRegistrationViewModel>(); DisplayRegistrationStatus(); }); ResetLayoutCommand = this.CreateCommand(() => View.OnResetLayout(settingsProvider)); OptionsCommand = this.CreateCommand(() => windowManager.ShowDialog <OptionsViewModel>()); }
public void TestInitialize() { argParser = Substitute.For <CommandLineArgParser>(); settingProvider = Substitute.For <ISettingsProvider>(); viewModel = new SearchBarViewModel(argParser, settingProvider); }
public void TestInitialize() { WindowManager = Substitute.For<WindowManagerEx>(); EndpointExplorer = Substitute.For<EndpointExplorerViewModel>(); MessageList = Substitute.For<MessageListViewModel>(); StatusbarManager = Substitute.For<StatusBarManager>(); EventAggregator = Substitute.For<IEventAggregator>(); MessageFlow = Substitute.For<MessageFlowViewModel>(); SagaWindow = Substitute.For<SagaWindowViewModel>(); MessageBodyView = Substitute.For<MessageBodyViewModel>(); MessageProperties = Substitute.For<MessagePropertiesViewModel>(); View = Substitute.For<IShellViewStub>(); HeaderView = Substitute.For<MessageHeadersViewModel>(); SequenceDiagramView = Substitute.For<SequenceDiagramViewModel>(); SettingsProvider = Substitute.For<ISettingsProvider>(); LicenseManager = Substitute.For<AppLicenseManager>(); LogWindow = Substitute.For<LogWindowViewModel>(); SettingsProvider.GetSettings<ProfilerSettings>().Returns(DefaultAppSetting()); App = Substitute.For<IAppCommands>(); CommandLineArgParser = MockEmptyStartupOptions(); shell = new ShellViewModel( App, WindowManager, EndpointExplorer, MessageList, () => Substitute.For<ServiceControlConnectionViewModel>(), () => Substitute.For<LicenseRegistrationViewModel>(), StatusbarManager, EventAggregator, LicenseManager, MessageFlow, SagaWindow, MessageBodyView, HeaderView, SequenceDiagramView, SettingsProvider, MessageProperties, LogWindow, CommandLineArgParser); ((IViewAware)shell).AttachView(View); }
public void TestInitialize() { ArgParser = Substitute.For<CommandLineArgParser>(); SettingProvider = Substitute.For<ISettingsProvider>(); ViewModel = new SearchBarViewModel(ArgParser, SettingProvider); }
CommandLineArgParser CreateSut() { var parser = new CommandLineArgParser(environment); parser.Parse(); return parser; }