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();
        }
Exemple #2
0
        public void The_Rule_Passes()
        {
            var set      = new MappingSetImpl();
            var entity   = new EntityImpl("Entity1");
            var property = new PropertyImpl("Property1");

            entity.AddProperty(property);
            set.EntitySet.AddEntity(entity);

            var table  = new Table("Table1");
            var column = new Column("Column1");

            table.AddColumn(column);
            set.Database.AddTable(table);

            set.ChangeMappedColumnFor(property).To(column);

            var rule   = new CheckAllPropertiesMappedRule();
            var result = rule.Run(set);

            Assert.That(result.HasIssues, Is.False);
        }