예제 #1
0
        public void Move_object_action_is_disabled_when_on_edge(string actionId)
        {
            using (var applicatin = PositionInListViewModuleModule().Application){
                var modelPositionInListView = applicatin.Model.ToReactiveModule <IModelReactiveModulesPositionInListView>()
                                              .PositionInListView;
                var listViewItem = modelPositionInListView.ListViewItems.AddNode <IModelPositionInListViewListViewItem>();
                listViewItem.ListView = applicatin.Model.BOModel.GetClass(typeof(PIL)).DefaultListView;
                var viewWindow  = applicatin.CreateViewWindow();
                var objectSpace = applicatin.CreateObjectSpace();
                PIL pil1        = null;
                PIL pil2        = null;
                var view        = applicatin.NewView(listViewItem.ListView,
                                                     space => new[] { space.GetObject(actionId == nameof(SwapPositionInListViewService.MoveObjectUp) ? pil1 : pil2) }, objectSpace);
                viewWindow.SetView(view);
                pil1      = objectSpace.CreateObject <PIL>();
                pil1.Name = "a";
                pil2      = objectSpace.CreateObject <PIL>();
                pil2.Name = "b";

                view.AsObjectView().OnSelectionChanged();


                viewWindow.Action(actionId).Enabled[SwapPositionInListViewService.EdgeContext].ShouldBeFalse();
            }
        }
        public void Move_object_action_is_disabled_when_on_edge(string disabledAction, string enabledAction)
        {
            using var application = PositionInListViewModuleModule().Application;

            var objectSpace = application.CreateObjectSpace();

            var viewWindow = application.CreateViewWindow();
            PIL pil1       = null;
            PIL pil2       = null;
            var view       = application.NewView(ListViewItem.ListView,
                                                 space => new[] { space.GetObject(disabledAction == nameof(SwapPositionInListViewService.MoveObjectUp) ? pil1 : pil2) }, objectSpace);

            viewWindow.SetView(view);
            pil1      = objectSpace.CreateObject <PIL>();
            pil1.Name = "a";
            pil2      = objectSpace.CreateObject <PIL>();
            pil2.Name = "b";
            objectSpace.CommitChanges();

            view.AsObjectView().OnSelectionChanged();


            viewWindow.Action(disabledAction).Enabled[SwapPositionInListViewService.EdgeContext].ShouldBeFalse();
            viewWindow.Action(enabledAction).Enabled[SwapPositionInListViewService.EdgeContext].ShouldBeTrue();
            view.AsListView().CollectionSource.Objects <PIL>().Count().ShouldBe(2);
        }