How do I generate xml mappings files as part of my tests in MappingIntegrationTests
I need to manually check if the fluent mappings correlate to the mappings in t
I use (almost) this extension method to get the xbm in memory so I can view it in my test project:
public static IDictionary LoadHBM(this FluentConfiguration cfg)
{
var result = new Dictionary();
var mem = new MemoryStream();
var writer = new StreamWriter(mem);
var reader = new StreamReader(mem);
cfg.Mappings(x =>
{
x.FluentMappings.ExportTo(writer);
x.AutoMappings.ExportTo(writer);
});
cfg.BuildConfiguration();
writer.Flush();
mem.Seek(0, 0);
var hbm = reader.ReadToEnd();
var objects = XElement.Parse("" + hbm + " ").Elements();
objects.ToList().ForEach(x => result.Add(x.Elements().First().Attribute("name").Value, x.ToString()));
return result;
}
Edit: Updated for FNH 1.2.