示例#1
0
        public void AddTriggerClicked_OkButtonSelected_TriggerCreated()
        {
            //Arrange
            var selectedPreset = _fixture.Create <PresetViewModel>();
            var selectedRegion = _fixture.Create <RegionViewModel>();

            selectedRegion.Triggers.Clear();
            var newTrigger = _fixture.Create <TriggerViewModel>();

            _regionConfigViewModel.SelectedRegion = selectedRegion;
            _regionConfigViewModel.SelectedPreset = selectedPreset;
            DialogMocker.InitializeInputDialog(newTrigger.Name, DialogResults.Ok);
            _triggerController.CreateTrigger(selectedPreset.Id, selectedRegion.Id, newTrigger.Name).Returns(newTrigger);

            _regionConfigViewModel.SelectedRegion.Triggers.Count.ShouldBe(0);

            //Act
            _regionConfigViewModel.AddTriggerClicked(null);

            //Assert
            _regionConfigViewModel.SelectedRegion.Triggers.Count.ShouldBe(1);
        }
示例#2
0
        public void AddTriggerClicked(object args)
        {
            if (InputDialogProvider.Show("New Trigger", "New Trigger Name:", DialogButtons.OkCancel) is InputDialogResult dialogResult && dialogResult.DialogResult == DialogResults.Ok)
            {
                if (string.IsNullOrWhiteSpace(dialogResult.Input))
                {
                    return;
                }

                var newTrigger = _triggerController.CreateTrigger(SelectedPreset.Id, SelectedRegion.Id, dialogResult.Input);

                SelectedRegion.Triggers.Add(newTrigger);
                SelectedTrigger = newTrigger;
            }
        }