예제 #1
0
        public void NewItemClicked(ButtonClickArgs e)
        {
            var title   = $"{e.Action} {e.ItemDescriptor}";
            var message = $"{e.Action} {e.ItemDescriptor}: ";

            var results = CrudDialogProvider.Show(new NestedViewModel <RegionViewModel>(title, message, new RegionViewModel(), DialogButtons.OkCancel));

            if (results.DialogResult != DialogResults.Ok)
            {
                return;
            }

            var newRegion = _regionController.Create(SelectedPreset.Id, results.InnerResults.Name);

            Regions.Add(newRegion);
            SelectedRegion = newRegion;
        }
        public void NewItemClicked_OkButtonSelected_RegionAddedToList()
        {
            //Arrange
            var selectedPreset = _fixture.Create <PresetViewModel>();
            var region         = _fixture.Create <RegionViewModel>();

            _regionControlViewModel.SelectedPreset = selectedPreset;
            _regionListController.Create(selectedPreset.Id, region.Name).Returns(region);
            DialogMocker.InitializeOkCancelDialog(region, DialogResults.Ok);

            _regionControlViewModel.Regions.Count.ShouldBe(0);

            //Act
            _regionControlViewModel.NewItemClicked(new ButtonClickArgs("Create", "Create"));

            //Assert
            _regionControlViewModel.Regions.Count.ShouldBe(1);
        }