public static ICLICommand Create(string command) { ICLICommand cliCommand; switch (command) { case OutletSearchCLIConstants.Commands.Clear: cliCommand = new ClearCommand(); break; case OutletSearchCLIConstants.Commands.Exit: cliCommand = new ExitCommand(); break; case OutletSearchCLIConstants.Commands.Help: cliCommand = new HelpCommand(); break; default: cliCommand = new SearchCommand(new OutletRepository()); break; } return(cliCommand); }
public void ClearCommandTest() { shape.Add(new Rectangle()); shape.Add(new Line()); clearCommand = new ClearCommand(model, shape); Assert.IsNotNull(model); }
public MainWindowViewModel() { #region starting view content logHandler = LogHandler.Instance; logHandler.MainWindowViewModel = this; ContentHandler.StartContent(); Refresh(); #endregion #region Commands AddUserCommand = new AddUserCommand(this); ViewProfilInfoCommand = new ViewProfilInfoCommand(this); AddTelephoneCommand = new AddTelephoneCommand(this); AddShopCommand = new AddShopCommand(this); ChangeTelephoneCommand = new ChangeTelephoneInfoCommand(this); DeleteTelephoneCommand = new DeleteTelephoneCommand(this); DuplicateTelephoneCommand = new DuplicateTelephoneCommand(this); ChangeShopCommand = new ChangeShopInfoCommand(this); DeleteShopCommand = new DeleteShopCommand(this); LogOutCommand = new LogOutCommand(this); BuyTelephoneCommand = new BuyTelephoneCommand(this); ClearCommand = new ClearCommand(this); UndoCommand = new UndoCommand(this); RedoCommand = new RedoCommand(this); FilterCommand = new FilterCommand(this); RefreshCommand = new RefreshCommand(this); #endregion }
public void CorrectlyPrintsCommandsToConsoleAfterAlias() { // arrange var console = new Mock <IConsole>(); var repl = new Mock <IRepl>(); var clearCommand = new ClearCommand(console.Object); var aliasCommand = new AliasCommand(console.Object); var commands = new Dictionary <string, IReplCommand> { { clearCommand.CommandName, clearCommand }, { aliasCommand.CommandName, aliasCommand }, }; repl.Setup(x => x.Commands).Returns(commands); var cmd = new HelpCommand(console.Object); aliasCommand.Execute(repl.Object, new[] { "clear", "clr" }); // act cmd.Execute(repl.Object, null); // assert console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(":" + clearCommand.CommandName) && f.Contains(clearCommand.Description))), Times.Once); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(":" + aliasCommand.CommandName) && f.Contains(aliasCommand.Description))), Times.Once); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(":clr") && f.Contains(clearCommand.Description))), Times.Once); }
public void Run() { while (true) { string input = Console.ReadLine(); ICommand Command; switch (input.ToUpper()) { case "CLEAR": Command = new ClearCommand(); Command.Execute(); break; case "VERSION": Command = new VersionCommand(); Command.Execute(); break; default: Command = new NullCommand(); Command.Execute(); break; } } }
public MainWindowViewModel(IDataAccess dataAccess = null, IShoppingListManager shoppingListManager = null) { // prepare for Unit Test DataAccess = dataAccess ?? new DataAccess(); ShoppingListManager = shoppingListManager ?? new ShoppingListManager(); // Get all data ShoppingLists = DataAccess.ToLoad(); // set WeekDay DayWeekTime = DateTime.Today.DayOfWeek; // Textbox: placeholder WantBuy = "e.g. apple ..."; // DataGrid: load data from Json, display on DataGrid todayShoppingList ToBuys = new ObservableCollection <ToBuy>(ShoppingListManager.TodayShoppingList(ShoppingLists)); // ClearButton ClearCommand = new ClearCommand(this); // AddButton AddCommand = new AddCommand(this); // Remove item Button RemoveSelectedCommand = new RemoveSelectedCommand(this); // arrange Button ArrangeCommand = new ArrangeCommand(this); // Monday ... Sunday Button MondayCommand = new MondayCommand(this); TuesdayCommand = new TuesdayCommand(this); WednesdayCommand = new WednesdayCommand(this); ThursdayCommand = new ThursdayCommand(this); FridayCommand = new FridayCommand(this); SaturdayCommand = new SaturdayCommand(this); SundayCommand = new SundayCommand(this); // print Btn PrintCommand = new PrintCommand(this); }
public void ToSaveClearCommandTest() { // fake LoadData var dataAccessMock = new Mock <IDataAccess>(); dataAccessMock.Setup(m => m.ToLoad()).Returns(MockShoppingList()); // input one Item var viewModel = new MainWindowViewModel(dataAccessMock.Object); // instance MainWindowViewModel viewModel.WantBuy = "newItem"; // pressed add button var addCommand = new AddCommand(viewModel); addCommand.Execute(null); // before clear Assert.AreEqual(viewModel.ToBuys.Count, 1); Assert.AreEqual(viewModel.ToBuys[0].Name, "newItem"); Assert.IsFalse(viewModel.ToBuys[0].IsDone); // clean item up var clearCommand = new ClearCommand(viewModel); clearCommand.Execute(null); // after clear Assert.AreEqual(viewModel.ToBuys.Count, 0); }
public void PrintsCommandsToConsole() { // arrange var console = new Mock <IConsole>(); var repl = new Mock <IRepl>(); var clearCommand = new ClearCommand(console.Object); var exitCommand = new ExitCommand(console.Object); var commands = new Dictionary <string, IReplCommand> { { clearCommand.CommandName, clearCommand }, { exitCommand.CommandName, exitCommand }, }; repl.Setup(x => x.Commands).Returns(commands); var cmd = new HelpCommand(console.Object); // act cmd.Execute(repl.Object, null); // assert console.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(3)); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(":" + clearCommand.CommandName) && f.Contains(clearCommand.Description))), Times.Once); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(":" + exitCommand.CommandName) && f.Contains(exitCommand.Description))), Times.Once); }
/// <summary> /// 表示物の消去を行う /// </summary> /// <param name="command"></param> /// <returns></returns> public async Task Clear(ClearCommand command) { switch (command.ClearTarget) { case EScenarioClearTargetType.All: // RemoveAllEmotion(command.FadeTimeMilliSecond); await RemoveAllStand(command.FadeTimeMilliSecond); _view.MessagePresenter.ClearText(); break; case EScenarioClearTargetType.Text: _view.MessagePresenter.ClearText(); break; case EScenarioClearTargetType.Face: _view.ClearFace(); break; case EScenarioClearTargetType.Left: case EScenarioClearTargetType.Center: case EScenarioClearTargetType.Right: // RemoveEmotion(EScenarioStandPositionExtension.GetEnum( // command.ClearTarget.GetName(), command.FadeTimeMilliSecond)); await RemoveStand(EScenarioStandPositionExtension.GetEnum( command.ClearTarget.GetName()), command.FadeTimeMilliSecond, true); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Конструктор MainWindowVM /// </summary> public MainWindowVM() { RectangulationCommand = new RectangulationCommand(); ClearCommand = new ClearCommand(); LeftClickCommand = new LeftClickCommand(); RightClickCommand = new RightClickCommand(); Shapes = new CompositeCollection(); Polygons = new ObservableCollection <PolygonVM>(); Rectangles = new ObservableCollection <RectangleVM>(); var polygonContainer = new CollectionContainer { Collection = Polygons }; Shapes.Add(polygonContainer); var rectangleContainer = new CollectionContainer { Collection = Rectangles }; Shapes.Add(rectangleContainer); CurrentPolygon = null; RectWidth = 20; RectHeight = 20; SelectedRectangleVM = null; }
public LoginViewModel(MainWindow window) { parentWindow = window; //_Employee = new Employee("Heathcote", "Joshua", "07/08/1987", "15 Milldale Avenue", "*****@*****.**", "01298 79867", "admin", "12345"); LoginCommand = new LoginCommand(this); ClearCommand = new ClearCommand(this); }
public void CorrectlyPrintsCommandsToConsoleAfterAlias() { // arrange var console = new Mock <IConsole>(); console.Setup(c => c.Width).Returns(80); var repl = new Mock <IRepl>(); var clearCommand = new ClearCommand(console.Object); var aliasCommand = new AliasCommand(console.Object); var commands = new Dictionary <string, IReplCommand> { { clearCommand.CommandName, clearCommand }, { aliasCommand.CommandName, aliasCommand }, }; repl.Setup(x => x.Commands).Returns(commands); var cmd = new HelpCommand(console.Object); aliasCommand.Execute(repl.Object, new[] { "clear", "clr" }); // act cmd.Execute(repl.Object, null); // assert // because we now have formatted wrapping with the description, we have to remove // all the extra spaces before verifying console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(" :" + clearCommand.CommandName) && f.Replace(" ", " ").Contains(clearCommand.Description))), Times.Once); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(" :" + aliasCommand.CommandName) && f.Replace(" ", " ").Contains(aliasCommand.Description))), Times.Once); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(" :clr") && f.Replace(" ", " ").Contains(clearCommand.Description))), Times.Once); }
public void Run(string[] args) { ProjectCommandLineApplication userJwts = new(_reporter) { Name = "dotnet user-jwts" }; userJwts.HelpOption("-h|--help"); // dotnet user-jwts list ListCommand.Register(userJwts); // dotnet user-jwts create CreateCommand.Register(userJwts); // dotnet user-jwts print ecd045 PrintCommand.Register(userJwts); // dotnet user-jwts remove ecd045 RemoveCommand.Register(userJwts); // dotnet user-jwts clear ClearCommand.Register(userJwts); // dotnet user-jwts key KeyCommand.Register(userJwts); // Show help information if no subcommand/option was specified. userJwts.OnExecute(() => userJwts.ShowHelp()); try { userJwts.Execute(args); } catch (Exception ex) { _reporter.Error(ex.Message); } } }
public Window30() { InitializeComponent(); ClearCommand clearCommand = new ClearCommand(); this.myCommandSource1.Command = clearCommand; this.myCommandSource1.CommandTarget = mniView1; }
public MainViewModel() { DrawCommand = new DrawCommand(this); ClearCommand = new ClearCommand(this); RebuildCommand = new RebuildCommand(this); OpenFileCommand = new OpenFileCommand(this); ExitCommand = new ExitCommand(); }
public void ReturnsClear() { // act var cmd = new ClearCommand(new Mock <IConsole>().Object); // assert Assert.Equal("clear", cmd.CommandName); }
public BookViewModel(IFileReader fileReader) { ShowCommand = new ShowCommand(this); UploadCommand = new UploadCommand(this); ClearCommand = new ClearCommand(this); Books = new ObservableCollection <Book>(); _fileReader = fileReader; }
public void Initialize() { _model = new Model(); _model.AddShape(new ShapeFactory().CreateShape(ShapeType.Line)); _model.AddShape(new ShapeFactory().CreateShape(ShapeType.SixSide)); _target = new PrivateObject(_model); _shapes = (List <Shape>)_target.GetField("_shapes"); _command = new ClearCommand(_model, _shapes); }
public MainViewModel(IDiagnosticsViewModel diagnosticsViewModel, ITabularDataService tabularDataService, IColumnsService columnsService, IOverlayService overlayService, IDateTimeService dateTimeService, ISchedulerService schedulerService) { _tabularDataService = tabularDataService; _schedulerService = schedulerService; _columnsService = columnsService; _overlayService = overlayService; _dateTimeService = dateTimeService; Diagnostics = diagnosticsViewModel; _dataIds = new Dictionary <object, DynamicDataViewModel>(1000); _data = new CustomTypeRangeObservableCollection <DynamicDataViewModel>(); _collectionView = new ListCollectionView(_data) { Filter = FilterData }; _updateStats = new Dictionary <long, int>(); RefreshCommand = ReactiveCommand.Create() .DisposeWith(this); ClearCommand = ReactiveCommand.Create() .DisposeWith(this); ColumnPickerCommand = ReactiveCommand.Create(HasDataChanged) .DisposeWith(this); _dataStream = InitialiseAndProcessDataAsync() .DisposeWith(this); RefreshCommand.Subscribe(x => Refresh()) .DisposeWith(this); ClearCommand.Subscribe(x => Clear()) .DisposeWith(this); ColumnPickerCommand.Subscribe(x => ShowColumnPicker()) .DisposeWith(this); _suspendNotifications = new SerialDisposable() .DisposeWith(this); FilterChanged.Subscribe(x => _collectionView.Refresh()) .DisposeWith(this); ColumnsChanged.ObserveOn(schedulerService.Dispatcher) .Subscribe(x => OnPropertyChanged(nameof(VisibleColumns))) .DisposeWith(this); Disposable.Create(() => Clear()) .DisposeWith(this); }
public MiniView() { InitializeComponent(); //声明命令并使用命令源和目标与之关联 ClearCommand clearCommand = new ClearCommand(); this.ctrlClear.Command = clearCommand; this.ctrlClear.CommandTarget = this.miniView; }
public void BackstackClear() { var expected = new JObject { { "type", "Back:Clear" } }; var goBack = ClearCommand.For(new BackstackExtension("Back")); Assert.True(JToken.DeepEquals(expected, JObject.FromObject(goBack))); }
public void Execute_Force_CallsClearCache() { _cacheManager.Setup(x => x.ClearCache()).Verifiable(); var target = new ClearCommand(_cacheManager.Object, new[] { "-f" }); target.Execute(); _cacheManager.Verify(); }
private void ModelOnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(SelectedItem) || e.PropertyName == nameof(Entities)) { OnPropertyChanged(e.PropertyName); AddCommand.RiseCanExecute(new object()); ClearCommand.RiseCanExecute(new object()); CreateOrderCommand.RiseCanExecute(new object()); } }
private void OnNewFunctionExecute(object parameter) { if (Controller != null) { Controller.Teardown(); } Controller = new DesignSurfaceController(this, new FunctionDefinition()); ClearCommand.RaiseCanExecuteChanged(); ClearCommand.RaiseCanExecuteChanged(); }
public MainViewModel(IPlatformService platformService, IJustDialService justDialService) { _platformService = platformService; _justDialService = justDialService; Version = _platformService.GetAssemblyVersion(); Listings = new ListingCollectionModel(); ClearCommand.Execute(null); }
public void GetCommand_ClearCommandArgument_ReturnsClearCommand() { var clearCommand = new ClearCommand(null, new [] { "-n" }); Func <string[], ClearCommand> factory = x => clearCommand; var target = new CommandFactory(null, null, null, null, null, null, null, factory); var command = target.GetCommand(new[] { CommandFactory.ClearArgument }); Assert.AreSame(clearCommand, command); }
void CreateCommands() { QuitCommand quitc = QuitCommand.CreateCommand(); ItemList listc = ItemList.CreateCommand(); HelpCommand helpc = HelpCommand.CreateCommand(); ClearCommand clearc = new ClearCommand(); Log(string.Format("A total of {0} commands exist.", CommandList.Keys.Count)); Log("Type 'help' for more info."); }
public RepeatableFlexPageViewModel(INavigationService navigationService, IPageDialogService pageDlg) { FlexDirection.Value = Xamarin.Forms.FlexDirection.Row; FlexAlignItems.Value = Xamarin.Forms.FlexAlignItems.Start; FlexJustify.Value = Xamarin.Forms.FlexJustify.Start; FlexWrap.Value = Xamarin.Forms.FlexWrap.NoWrap; ScrollDirection.Value = ScrollOrientation.Horizontal; SetColors(DirectionColor, 0); SetColors(AColor, 3); SetColors(JColor, 3); SetColors(WrapColor, 0); DirectionCommand.Subscribe(x => { var idx = int.Parse(x); FlexDirection.Value = (Xamarin.Forms.FlexDirection)idx; SetScrollDirection(); SetColors(DirectionColor, idx); }); AlignItemsCommand.Subscribe(x => { var idx = int.Parse(x); FlexAlignItems.Value = (Xamarin.Forms.FlexAlignItems)idx; SetColors(AColor, idx); }); JustifyContentCommand.Subscribe(x => { var idx = int.Parse(x); FlexJustify.Value = (Xamarin.Forms.FlexJustify)idx; SetColors(JColor, idx); }); WrapCommand.Subscribe(x => { var idx = int.Parse(x); FlexWrap.Value = (Xamarin.Forms.FlexWrap)idx; SetScrollDirection(); SetColors(WrapColor, idx); }); BoxList = new ObservableCollection <Hoge>(Shuffle()); AddCommand.Subscribe(_ => { BoxList.Add(GetNextItem()); }); DeleteCommand.Subscribe(_ => { BoxList.Remove(BoxList.Last()); }); ReplaceCommand.Subscribe(__ => { BoxList[0] = GetNextItem(); }); ClearCommand.Subscribe(__ => { BoxList.Clear(); }); }
private void RiseControl() { SearchCommand?.RiseCanExecute(); ClearCommand?.RiseCanExecute(); CatalogNavigateViewModel.FirstCommand.RiseCanExecute(); CatalogNavigateViewModel.PreviousCommand.RiseCanExecute(); CatalogNavigateViewModel.NextCommand.RiseCanExecute(); CatalogNavigateViewModel.LastCommand.RiseCanExecute(); SetEnabled(!HasError.Value); Messenger?.Send(CommandName.EnableMenu, new EnableMenuEventArgs(!HasError.Value)); }
public void Execute_DryRun_DoesNotClearCache() { // mock is strict, so calling ClearCache will throw _cacheManager.Setup(x => x.ListFiles()).Returns(new GitBinFileInfo[0]); var target = new ClearCommand(_cacheManager.Object, new[] { "-n" }); target.Execute(); Assert.Pass(); }