Esempio n. 1
0
        public IndexPresenter(IMainPanel panel, IIndexForm form)
            : base(panel)
        {
            this.form = form;

            SetupForm();

            form.IndexNameChanged += (sender, e) => { if (!Detached)
                                                      {
                                                          Index.Name = form.IndexName;
                                                      }
            };
            form.DatatypeChanged += (sender, e) => { if (!Detached)
                                                     {
                                                         Index.Datatype = form.Datatype;
                                                     }
            };
            form.DescriptionChanged += (sender, e) => { if (!Detached)
                                                        {
                                                            Index.Description = form.Description;
                                                        }
            };
            form.SelectedColumnChanged += (sender, e) => { if (!Detached)
                                                           {
                                                               mainPanel.ShowObjectPropertyGrid(form.SelectedColumn);
                                                           }
            };
            form.DeleteColumn += form_DeleteColumn;
        }
Esempio n. 2
0
        public void Clear_Called()
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            IIndex     obj   = MockRepository.GenerateMock <IIndex>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //var presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);

            form.AssertWasCalled(f => f.Clear());
        }
Esempio n. 3
0
        public void Property_Changed_Registered()
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            IIndex     obj   = MockRepository.GenerateMock <IIndex>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //var presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);

            obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments());
        }
Esempio n. 4
0
        public void Show_Property_Grid_Called()
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            IIndex     obj   = MockRepository.GenerateMock <IIndex>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //IndexPresenter presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);
            //presenter.Show();

            //panel.AssertWasCalled(p => p.ShowPropertyGrid(form));
        }
Esempio n. 5
0
        public void Events_Are_Registered()
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //new IndexPresenter(panel, form);

            form.AssertWasCalled(f => f.DatatypeChanged       += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.DescriptionChanged    += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.IndexNameChanged      += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.SelectedColumnChanged += null, c => c.IgnoreArguments());
            form.AssertWasCalled(f => f.DeleteColumn          += null, c => c.IgnoreArguments());
        }
Esempio n. 6
0
        private void Test_Property_Called(Action <Index> setPropertyAction, Action <IIndexForm> action)
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            Index      obj   = new Index("Index1");
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //var presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);

            setPropertyAction(obj);

            form.AssertWasCalled(action);
        }
Esempio n. 7
0
        public IndexPresenter(IMainPanel panel, IIndexForm form)
            : base(panel)
        {
            this.form = form;

            SetupForm();

            form.IndexNameChanged += (sender, e) => { if (!Detached) Index.Name = form.IndexName; };
            form.DatatypeChanged += (sender, e) => { if (!Detached) Index.Datatype = form.Datatype; };
            form.DescriptionChanged += (sender, e) => { if (!Detached) Index.Description = form.Description; };
            form.SelectedColumnChanged += (sender, e) => { if (!Detached) mainPanel.ShowObjectPropertyGrid(form.SelectedColumn); };
            form.DeleteColumn += form_DeleteColumn;
        }
Esempio n. 8
0
        public void The_Form_Is_Filled()
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            IIndex     obj   = MockRepository.GenerateMock <IIndex>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //IndexPresenter presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);

            form.AssertWasCalled(f => f.Datatype    = obj.Datatype);
            form.AssertWasCalled(f => f.Description = obj.Description);
            form.AssertWasCalled(f => f.IndexName   = obj.Name);
            form.AssertWasCalled(f => f.Columns     = obj.Columns);
            form.AssertWasCalled(f => f.SetVirtualProperties(obj.Ex));
        }
Esempio n. 9
0
        private void Property_Changed_Called_After_Form_Updates(Action <IIndexForm> setFormPropertyReturnValue,
                                                                Action <IIndexForm> @event, Action <IIndexForm> expectedCall, object newPropertyValue, Func <Index, object> getParameter)
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            Index      obj   = new Index("Index1");
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //var presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);

            IEventRaiser raiser = form.GetEventRaiser(@event);

            setFormPropertyReturnValue(form);

            raiser.Raise(form, null);

            form.AssertWasCalled(expectedCall);
            Assert.That(getParameter(obj), Is.EqualTo(newPropertyValue));
        }
Esempio n. 10
0
        public void Column_Selection_Changed_Called()
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            IIndex     obj   = MockRepository.GenerateStub <IIndex>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //var presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);

            Column toReturn = new Column("Column1");

            form.Stub(o => o.SelectedColumn).Return(toReturn);

            // Raise the PropertyChanged event for the Columns collection on the Key
            IEventRaiser raiser = form.GetEventRaiser(e => e.SelectedColumnChanged += null);

            raiser.Raise(obj, null);

            panel.AssertWasCalled(p => p.ShowObjectPropertyGrid(toReturn));
        }
Esempio n. 11
0
        public void Columns_Changed_Called()
        {
            IIndexForm form  = MockRepository.GenerateMock <IIndexForm>();
            IIndex     obj   = MockRepository.GenerateStub <IIndex>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            //var presenter = new IndexPresenter(panel, form);
            //presenter.AttachToModel(obj);

            List <IColumn> columns = new List <IColumn>();

            obj.Stub(o => o.Columns).Return(columns);

            // Raise the PropertyChanged event for the Columns collection on the Index
            IEventRaiser raiser = obj.GetEventRaiser(e => e.PropertyChanged += null);

            raiser.Raise(obj, new PropertyChangedEventArgs("Columns"));

            form.AssertWasCalled(f => f.Columns = columns);
        }