I want to be able to add to my Mappings Action dynamically, so that when I run a particular integration test I can export the mappings to an xml file.
So I have the following setup for my Mappings:
private static Action<MappingConfiguration> _mappings;
public static Action<MappingConfiguration> Mappings
{
get { return _mappings ?? (_mappings = CreateFluentMappings()); }
}
private static Action<MappingConfiguration> CreateFluentMappings()
{
return m => m.FluentMappings.AddFromAssemblyOf<UserMapping>();
}
and when I build my session I do this:
return Fluently.Configure()
.Database(
MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromAppSetting("connstring"))
.ProxyFactoryFactory<ProxyFactoryFactory>()
.ShowSql()
)
.Mappings(Mappings);
and I have a test I'm trying to build that will export the xml file:
[Test]
public void SessionFactory_WhenGetting_CanOutputToXml()
{
//arrange
var mappings = SessionFactoryBuilder.Mappings;
//act
//I want to add an extra line to the action here to tell it to Export to XML
//??????
mappings(m => m.FluentMappings.ExportTo(@"c:\Mappings\myMappings.xml"));
//assert
Assert.That(File.Exists(@"c:\Mappings\myMappings.xml"), Is.True);
}
My problem is in my act part of my test, I don't know what syntax to use to append an additional piece of code into the action.
Is this possible or do I have to create a completely new action?