public void The_Presenter_Refreshes_The_Database_And_Attempts_To_Show_The_Results() { IDatabaseForm form = MockRepository.GenerateMock <IDatabaseForm>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); IDatabase db = MockRepository.GenerateStub <IDatabase>(); db.Stub(d => d.Tables).Return(new ReadOnlyCollection <ITable>(new List <ITable>())); var presenter = new DatabasePresenter(panel, form); presenter.AttachToModel(db); AutoResetEvent arEvent = new AutoResetEvent(false); presenter.SchemaRefreshed += (sender, e) => arEvent.Set(); form.Stub(t => t.SelectedDatabaseType).Return(DatabaseTypes.SQLCE); form.Stub(t => t.SelectedDatabase).Return("1Table3Columns.sdf"); var raiser = form.GetEventRaiser(t => t.RefreshSchema += null); raiser.Raise(form, null); Assert.That(arEvent.WaitOne(10000, true), "The test timed out waiting for the SchemaRefreshed event to be triggered"); panel.AssertWasCalled(p => p.ShowDatabaseRefreshResults( Arg <DatabaseMergeResult> .Matches(t => t.TableOperations.Count() == 1))); }
public void Show_Property_Grid_Called() { IComponentForm form = MockRepository.GenerateMock <IComponentForm>(); Component obj = MockRepository.GenerateMock <Component>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //ComponentPresenter presenter = new ComponentPresenter(panel, form); //presenter.AttachToModel(obj); //presenter.Show(); panel.AssertWasCalled(p => p.ShowPropertyGrid(form)); }
public void Show_Property_Grid_Called() { IEntityForm form = MockRepository.GenerateMock <IEntityForm>(); Entity obj = MockRepository.GenerateStub <Entity>(); obj.Key = new EntityKeyImpl(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); EntityPresenter presenter = new EntityPresenter(panel, form); presenter.AttachToModel(obj); presenter.Show(); panel.AssertWasCalled(p => p.ShowPropertyGrid(form)); }
public void Show_Property_Grid_Called() { IComponentSpecificationForm form = MockRepository.GenerateMock <IComponentSpecificationForm>(); ComponentSpecification obj = MockRepository.GenerateMock <ComponentSpecification>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); obj.Stub(o => o.ImplementedComponents).Return(new List <Component>().AsReadOnly()); obj.Stub(o => o.EntitySet).Return(new EntitySetImpl()); ComponentSpecificationPresenter presenter = new ComponentSpecificationPresenter(panel, form); presenter.AttachToModel(obj); presenter.Show(); panel.AssertWasCalled(p => p.ShowPropertyGrid(form)); }
public void New_Column_Added_Correctly() { ICollectionForm <IColumn> form = MockRepository.GenerateMock <ICollectionForm <IColumn> >(); IColumnContainer obj = MockRepository.GenerateMock <IColumnContainer>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = new ColumnCollectionPresenter(panel, form); //presenter.AttachToModel(obj); //presenter.Show(); var raiser = form.GetEventRaiser(f => f.AddItem += null); raiser.Raise(form, new EventArgs()); panel.AssertWasCalled(p => p.ShowObjectPropertyGrid(Arg <Column> .Matches(c => c != null && c.Name == "NewColumn"))); //panel.AssertWasCalled(p => p.ShowPropertyGrid(form)); form.AssertWasCalled(f => f.Clear()); obj.AssertWasCalled(o => o.AddColumn(Arg <Column> .Matches(c => c != null && c.Name == "NewColumn"))); }
public void Column_Selection_Changed_Called() { IKeyForm form = MockRepository.GenerateMock <IKeyForm>(); IKey obj = MockRepository.GenerateStub <IKey>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = new KeyPresenter(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.EditColumn += null); raiser.Raise(obj, null); panel.AssertWasCalled(p => p.ShowObjectPropertyGrid(toReturn)); }
public void Triggering_The_RemoveEntity_Event_Removes_It_From_The_Model_And_Clears_The_Screen() { IMainPanel mainPanel = MockRepository.GenerateStub <IMainPanel>(); IEntityForm form = MockRepository.GenerateMock <IEntityForm>(); Entity entity = new EntityImpl("Entity1"); EntitySet entitySet = new EntitySetImpl(); entitySet.AddEntity(entity); var presenter = new EntityPresenter(mainPanel, form); presenter.AttachToModel(entity); form.Raise(f => f.RemoveEntity += null, form, new EventArgs()); Assert.That(entity.EntitySet, Is.Null); Assert.That(entitySet.Entities.Count(), Is.EqualTo(0)); // Assert that the main panel was instructed to clear the property grid. mainPanel.AssertWasCalled(m => m.ShowPropertyGrid(null)); }