public void It_Should_Deserialise_To_This() { const string xml = When_Serialising_A_RelationshipMapping_With_All_Fields_Set.FullMappingXml; RelationshipReferenceMapping mapping = new MappingSetDeserialisationScheme().DeserialiseRelationshipMapping(xml.GetXmlDocRoot(), database, entitySet); TestMapping(mapping, relationship, reference); }
public void It_Should_Deserialise_To_This() { var xml = When_Serialising_A_Mapping_With_All_Fields_Set.FullMappingXml; Mapping mapping = new MappingSetDeserialisationScheme().DeserialiseMapping(xml.GetXmlDocRoot(), database, entitySet); TestMapping(mapping, table, entity1); }
public void It_Should_Deserialise_To_This() { var xml = "<MappingSet />"; Database database = new Database("DB1"); EntitySet entitySet = new EntitySetImpl(); MappingSet set = new MappingSetDeserialisationScheme().DeserialiseMappingSet(xml.GetXmlDocRoot(), database, entitySet); Assert.That(set.EntitySet, Is.SameAs(entitySet)); Assert.That(set.Database, Is.SameAs(database)); }
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 } }
public void It_Should_Deserialise_To_This() { var xml = Specs_For_Serialisation_Of_MappingSets.When_Serialising_A_MappingSet_With_Mappings.FullMappingSetXml; var testData = new When_Deserialising_A_Mapping_With_All_Fields_Set(); testData.Setup(); MappingSet set = new MappingSetDeserialisationScheme().DeserialiseMappingSet(xml.GetXmlDocRoot(), testData.database, testData.entitySet); Assert.That(set.EntitySet, Is.SameAs(testData.entitySet)); Assert.That(set.Database, Is.SameAs(testData.database)); Assert.That(set.Mappings.Count, Is.EqualTo(1)); Assert.That(set.ReferenceMappings.Count, Is.EqualTo(1)); When_Deserialising_A_Mapping_With_All_Fields_Set.TestMapping(set.Mappings[0], testData.table, testData.entity1); When_Deserialising_A_ReferenceMapping_With_All_Fields_Set.TestMapping(set.ReferenceMappings[0], testData.table, testData.entity1.References[0]); }
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 } }