public void Form_Is_Set_Up()
        {
            IComponentSpecificationForm form = MockRepository.GenerateMock <IComponentSpecificationForm>();
            IMainPanel panel = MockRepository.GenerateMock <IMainPanel>();

            var mappingSet = new MappingSetImpl();
            var entity     = new EntityImpl("Entity1");

            entity.AddProperty(new PropertyImpl("Property1"));
            var table = new Table("Table1");

            table.AddColumn(new Column("Column1"));
            table.AddColumn(new Column("Street"));
            mappingSet.EntitySet.AddEntity(entity);

            mappingSet.ChangeMappedColumnFor(entity.Properties.First()).To(table.Columns[0]);

            ComponentSpecification spec = new ComponentSpecificationImpl("Address");

            spec.AddProperty(new ComponentPropertyImpl("Street"));
            Component component = spec.CreateImplementedComponentFor(entity, "Street");

            mappingSet.EntitySet.AddComponentSpecification(spec);

            var mapping = new ComponentMappingImpl {
                ToComponent = component, FromTable = table
            };

            mapping.AddPropertyAndColumn(component.Properties[0], table.Columns[0]);
            mappingSet.AddMapping(mapping);

            form.Expect(f => f.SetProperties(null))
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <ComponentProperty>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            form.Expect(f => f.SetUsages(null))
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <Entity>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            form.Expect(f => f.SetFullEntityList(null))
            .IgnoreArguments()
            .WhenCalled(action => Assert.That(((IEnumerable <Entity>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            ComponentSpecificationPresenter presenter = new ComponentSpecificationPresenter(panel, form);

            presenter.AttachToModel(spec);

            form.AssertWasCalled(f => f.Clear());
            form.AssertWasCalled(f => f.SpecName = spec.Name);
            form.AssertWasCalled(f => f.SetVirtualProperties(spec.Ex));

            form.VerifyAllExpectations();
        }
        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 Property_Changed_Registered()
        {
            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);

            obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments());
            obj.AssertWasCalled(o => o.ImplementedComponentsChanged += null, c => c.IgnoreArguments());
            obj.AssertWasCalled(o => o.PropertiesChanged            += null, c => c.IgnoreArguments());
        }
        public void Form_Is_Set_Up()
        {
            IComponentSpecificationForm form = MockRepository.GenerateMock<IComponentSpecificationForm>();
            IMainPanel panel = MockRepository.GenerateMock<IMainPanel>();

            var mappingSet = new MappingSetImpl();
            var entity = new EntityImpl("Entity1");
            entity.AddProperty(new PropertyImpl("Property1"));
            var table = new Table("Table1");
            table.AddColumn(new Column("Column1"));
            table.AddColumn(new Column("Street"));
            mappingSet.EntitySet.AddEntity(entity);

            mappingSet.ChangeMappedColumnFor(entity.Properties.First()).To(table.Columns[0]);

            ComponentSpecification spec = new ComponentSpecificationImpl("Address");
            spec.AddProperty(new ComponentPropertyImpl("Street"));
            Component component = spec.CreateImplementedComponentFor(entity, "Street");
            mappingSet.EntitySet.AddComponentSpecification(spec);

            var mapping = new ComponentMappingImpl {ToComponent = component, FromTable = table};
            mapping.AddPropertyAndColumn(component.Properties[0], table.Columns[0]);
            mappingSet.AddMapping(mapping);

            form.Expect(f => f.SetProperties(null))
                .IgnoreArguments()
                .WhenCalled(action => Assert.That(((IEnumerable<ComponentProperty>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            form.Expect(f => f.SetUsages(null))
                .IgnoreArguments()
                .WhenCalled(action => Assert.That(((IEnumerable<Entity>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            form.Expect(f => f.SetFullEntityList(null))
                .IgnoreArguments()
                .WhenCalled(action => Assert.That(((IEnumerable<Entity>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            ComponentSpecificationPresenter presenter = new ComponentSpecificationPresenter(panel, form);
            presenter.AttachToModel(spec);

            form.AssertWasCalled(f => f.Clear());
            form.AssertWasCalled(f => f.SpecName = spec.Name);
            form.AssertWasCalled(f => f.SetVirtualProperties(spec.Ex));

            form.VerifyAllExpectations();
        }
        public void Property_Changed_Registered()
        {
            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);

            obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments());
            obj.AssertWasCalled(o => o.ImplementedComponentsChanged += null, c => c.IgnoreArguments());
            obj.AssertWasCalled(o => o.PropertiesChanged += null, c => c.IgnoreArguments());
        }
        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));
        }