public void It_Should_Serialise_To_This() { EntitySet entitySet = new EntitySetDeserialisationScheme().DeserialiseEntitySet(BasicEntitySetXml.GetXmlDocRoot(), null); Assert.That(entitySet.Entities, Is.Empty); Assert.That(entitySet.References, Is.Empty); }
public void It_Should_Create_This() { EntityKey key = new EntitySetDeserialisationScheme().DeserialiseKey(BasicEntityXml.GetXmlDocRoot(), new EntityImpl()); Assert.That(key, Is.Not.Null); Assert.That(key.Properties, Is.Empty); Assert.That(key.Component, Is.Null); Assert.That(key.KeyType, Is.EqualTo(EntityKeyType.Empty)); }
public void It_Should_Serialise_To_This() { var dis = new EntitySetDeserialisationScheme().DeserialiseDiscriminator(BasicDiscriminatorXml.GetXmlDocRoot(), null); Assert.That(dis, Is.Not.Null); Assert.That(dis.RootGrouping, Is.Not.Null); Assert.That(dis.RootGrouping.ContainsConditions, Is.False); Assert.That(dis.RootGrouping.ContainsGroupings, Is.False); }
public void It_Should_Create_This() { const string xml = When_Serialising_A_ComponentProperty.BasicPropertyXml; ComponentSpecification spec = new ComponentSpecificationImpl(); ComponentProperty prop = new EntitySetDeserialisationScheme().DeserialiseComponentProperty(xml.GetXmlDocRoot(), spec); Assert.That(prop.Specification, Is.SameAs(spec)); Assert.That(prop.Name, Is.EqualTo("Street")); Assert.That(prop.ValidationOptions, Is.Not.Null); Assert.That(prop.Type, Is.EqualTo("object")); }
public void It_Should_Create_This() { const string xml = When_Serialising_An_Empty_Property.BasicPropertyXml; var parentEntity = new EntityImpl(); Property prop = new EntitySetDeserialisationScheme().DeserialiseProperty(xml.GetXmlDocRoot(), parentEntity); Assert.That(prop.Entity, Is.SameAs(parentEntity)); Assert.That(prop.Name, Is.EqualTo("")); Assert.That(prop.ReadOnly, Is.False); Assert.That(prop.ValidationOptions, Is.Not.Null); Assert.That(prop.Type, Is.EqualTo("object")); Assert.That(prop.IsKeyProperty, Is.False); //Assert.That(prop.IsVirtual, Is.False); }
public void It_Should_Create_This() { const string xml = When_Serialising_A_Property_With_All_Fields_Set.FullPropertyXml; var parentEntity = new EntityImpl(); Property prop = new EntitySetDeserialisationScheme().DeserialiseProperty(xml.GetXmlDocRoot(), parentEntity); Assert.That(prop.Entity, Is.SameAs(parentEntity)); Assert.That(prop.Name, Is.EqualTo("Property1")); Assert.That(prop.ReadOnly, Is.True); Assert.That(prop.ValidationOptions, Is.Not.Null); Assert.That(prop.Type, Is.EqualTo("SomeType")); Assert.That(prop.IsKeyProperty, Is.True); //Assert.That(prop.IsVirtual, Is.True); }
public void It_Should_Create_This() { Entity parentEntity = new EntityImpl(); Component component = new ComponentImpl {Name = "Component_Name"}; parentEntity.AddComponent(component); Property prop = new PropertyImpl { Name = "Property1" }; parentEntity.AddProperty(prop); EntityKey key = new EntitySetDeserialisationScheme().DeserialiseKey(FullEntityXml.GetXmlDocRoot(), parentEntity); Assert.That(key.Properties.Count(), Is.EqualTo(1)); Assert.That(key.Properties.ElementAt(0), Is.SameAs(prop)); Assert.That(key.Component, Is.SameAs(component)); Assert.That(key.KeyType, Is.EqualTo(EntityKeyType.Properties)); }
public void It_Should_Deserialise_To_This() { const string xml = Specs_For_Serialisation_Of_Entities.When_Serialising_An_Empty_Entity.BasicEntityXml; var scheme = new EntitySetDeserialisationScheme(); Entity entity = scheme.DeserialiseEntity(xml.GetXmlDocRoot()); scheme.PostProcessEntity(new EntitySetImpl(), null, entity, xml.GetXmlDocRoot()); Assert.That(entity.Name, Is.EqualTo("")); Assert.That(entity.Key.Properties, Is.Empty); Assert.That(entity.Properties, Is.Empty); Assert.That(entity.References, Is.Empty); Assert.That(entity.Discriminator, Is.Null, "The deserialisation of the Discriminator should happen in the post process step."); Assert.That(entity.HasParent, Is.False); }
public void It_Should_Create_This() { const string xml = When_Serialising_A_ComponentSpecification.BasicSpecXml; var parentEntity = new EntityImpl("Entity1"); var entitySet = new EntitySetImpl(); entitySet.AddEntity(parentEntity); ComponentSpecification spec = new EntitySetDeserialisationScheme().DeserialiseComponentSpecification(xml.GetXmlDocRoot(), entitySet); Assert.That(spec.Name, Is.EqualTo("Address")); Assert.That(spec.Properties, Has.Count(1)); Assert.That(spec.Properties[0].Name, Is.EqualTo("Street")); Assert.That(spec.ImplementedComponents, Has.Count(1)); Assert.That(spec.ImplementedComponents[0].ParentEntity, Is.SameAs(parentEntity)); }
public void It_Should_Serialise_To_This() { EntitySet entitySet = new EntitySetDeserialisationScheme().DeserialiseEntitySet(FullEntitySetXml.GetXmlDocRoot(), null); Assert.That(entitySet.Entities.Count(), Is.EqualTo(2)); Assert.That(entitySet.References.Count(), Is.EqualTo(1)); var entity1 = entitySet.Entities.ElementAt(0); var entity2 = entitySet.Entities[1]; var reference = entitySet.References.ElementAt(0); Assert.That(entity1.Name, Is.EqualTo("Entity1")); Assert.That(entity1.HasParent, Is.True); Assert.That(entity1.Parent, Is.SameAs(entity2)); Assert.That(entity2.Name, Is.EqualTo("Entity2")); Assert.That(reference.Entity1, Is.SameAs(entity2)); Assert.That(reference.Entity2, Is.SameAs(entity1)); }
public void It_Should_Create_This() { const string xml = When_Serialising_A_Component.BasicComponentXml; var parentEntity = new EntityImpl("Entity1"); var entitySet = new EntitySetImpl(); entitySet.AddEntity(parentEntity); var spec = new ComponentSpecificationImpl("Address"); spec.AddProperty(new ComponentPropertyImpl("Street")); spec.EntitySet = entitySet; Component comp = new EntitySetDeserialisationScheme().DeserialiseComponent(xml.GetXmlDocRoot(), spec); Assert.That(comp.Name, Is.EqualTo("HomeAddress")); Assert.That(comp.ParentEntity, Is.SameAs(parentEntity)); Assert.That(comp.Specification, Is.SameAs(spec)); Assert.That(comp.Properties, Has.Count(1)); Assert.That(comp.Properties[0].RepresentedProperty, Is.SameAs(spec.Properties[0])); }
public void It_Should_Serialise_To_This() { XmlNode root = When_Serialising_A_Discriminator_With_One_Condition.FullDiscriminatorXml.GetXmlDocRoot(); Entity entity = new EntityImpl("Entity1"); var column = new Column("Column1"); Table table = new Table("Table1"); table.AddColumn(column); var database = new Database("db1"); database.AddTable(table); var dis = new EntitySetDeserialisationScheme().DeserialiseDiscriminator(root, database); Assert.That(dis, Is.Not.Null); Assert.That(dis.RootGrouping, Is.Not.Null); Assert.That(dis.RootGrouping.ContainsConditions, Is.True); Assert.That(dis.RootGrouping.ContainsGroupings, Is.False); var condition = dis.RootGrouping.Conditions.ElementAt(0); Assert.That(condition.Column, Is.SameAs(column)); Assert.That(condition.Operator, Is.SameAs(Operator.Equal)); Assert.That(condition.ExpressionValue.Value, Is.EqualTo("5")); }
public void It_Should_Deserialise_To_This() { const string xml = Specs_For_Serialisation_Of_Entities.When_Serialising_An_Entity_With_All_Fields_Set.FullEntityXml; var scheme = new EntitySetDeserialisationScheme(); XmlNode root = xml.GetXmlDocRoot(); Entity entity = scheme.DeserialiseEntity(root); Entity entity2 = new EntityImpl("Entity2"); EntitySet entitySet = new EntitySetImpl(); entitySet.AddEntity(entity); entitySet.AddEntity(entity2); scheme.PostProcessEntity(entitySet, null, entity, root); Assert.That(entity.Name, Is.EqualTo("Entity1")); Assert.That(entity.Key, Is.Not.Null); // Don't both checking the contents of the Properties collection, // as long as it had something added to it. The tests on deserialising // properties will catch most bugs. Assert.That(entity.Properties, Is.Not.Empty); Assert.That(entity.Discriminator, Is.Not.Null, "The deserialisation of the Discriminator should happen in the post process step."); Assert.That(entity.HasParent, Is.True); Assert.That(entity.Parent, Is.SameAs(entity2)); }
public override void Open(string folder) { string databaseFilePath = Path.Combine(folder, DatabaseFilename); string entityFilePath = Path.Combine(folder, EntitiesFilename); string mappingsFilePath = Path.Combine(folder, MappingsFilename); if (File.Exists(databaseFilePath) == false) throw new ArgumentException("Database definition file missing."); if (File.Exists(entityFilePath) == false) throw new ArgumentException("Entity definition file missing."); if (File.Exists(mappingsFilePath) == false) throw new ArgumentException("Mapping definition file missing."); string databaseXml = File.ReadAllText(databaseFilePath); string entitiesXml = File.ReadAllText(entityFilePath); string mappingsXml = File.ReadAllText(mappingsFilePath); try { var database = new DatabaseDeserialisationScheme().Deserialise(databaseXml); var entitySet = new EntitySetDeserialisationScheme().DeserialiseEntitySet(entitiesXml, database); MappingSet = new MappingSetDeserialisationScheme().DeserialiseMappingSet(mappingsXml, database, entitySet); // If everything loaded correctly, copy the database file away so we can use it to figure out what the user has changed // in this session. loadedDatabaseXML = databaseXml; } catch (Exception e) { log.ErrorFormat("Error opening Entity Model Provider files on disk"); log.Error(e.Message); #if DEBUG if (MessageBox.Show("An error occurred while opening the project files.\nDo you want to ignore the invalid model on disk? See logs for exception", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { Clear(); } else { throw; } #endif } }