public void A_ToComponent__It_Should_Throw_An_Exception()
        {
            var mapping = new ComponentMappingImpl();

            mapping.FromTable = new Table();
            new MappingSetSerialisationScheme().SerialiseComponentMapping(mapping);
        }
        public static ComponentMapping GetMapping()
        {
            ComponentMapping mapping = new ComponentMappingImpl();

            mapping.FromTable = new Table("Table1");
            mapping.FromTable.AddColumn(new Column("AddressStreet"));
            mapping.ToComponent = new ComponentImpl(new ComponentSpecificationImpl("Address"), new EntityImpl("Entity1"), "HomeAddress");
            mapping.ToComponent.AddProperty(new ComponentPropertyMarker(new ComponentPropertyImpl("Street")));
            mapping.AddPropertyAndColumn(mapping.ToComponent.Properties[0], mapping.FromTable.Columns[0]);

            return(mapping);
        }
        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();
        }