public void It_Should_Serialise_To_This() { var set = new MappingSetImpl(); set.AddMapping(When_Serialising_A_Mapping_With_All_Fields_Set.GetMapping()); set.AddMapping(When_Serialising_A_ReferenceMapping_With_All_Fields_Set.GetMapping()); string outputXML = new MappingSetSerialisationScheme().SerialiseMappingSet(set); outputXML = XmlSqueezer.RemoveWhitespaceBetweenElements(outputXML); Assert.That(outputXML, Is.EqualTo(FullMappingSetXml)); }
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 It_Is_Deleted() { MappingSet ms = new MappingSetImpl(); Mapping m = new MappingImpl(); ms.AddMapping(m); Assert.That(ms.Mappings.Contains(m)); m.Delete(); Assert.That(ms.Mappings.Contains(m) == false); }
public void The_Mapping_Should_Be_Deleted() { var m = new MappingImpl(); var ms = new MappingSetImpl(); ms.AddMapping(m); Assert.That(ms.Mappings.Contains(m), Is.True); //presenter.AttachToModel(m); form.Raise(f => f.RemoveMapping += null, form, new EventArgs()); Assert.That(ms.Mappings.Contains(m), Is.False); }
public void Setup() { EntitySet entitySet = new EntitySetImpl(); entity = new EntityImpl("Entity1"); entity.AddProperty(new PropertyImpl { Name = "Property1" }); entitySet.AddEntity(entity); IDatabase database = new Database("DB1"); table = new Table("Table"); table.AddColumn(new Column("Column1")); database.AddEntity(table); Mapping mapping = new MappingImpl(); mapping.AddPropertyAndColumn(entity.Properties.ElementAt(0), table.Columns[0]); MappingSet mappingSet = new MappingSetImpl(database, entitySet); mappingSet.AddMapping(mapping); }