public static void MyClassInitialize(TestContext testContext)
{
try {
IPersistenceConfigurer persistenceConfigurer = MySQLConfiguration.Standard.ConnectionString(c => c.Is("Server=localhost;Database=basicproject;User ID=root;Password=1234")).ShowSql();
// initialize nhibernate with persistance configurer properties
Configuration cfg = persistenceConfigurer.ConfigureProperties(new Configuration());
// add mappings definition to nhibernate configuration
var persistenceModel = new PersistenceModel();
persistenceModel.AddMappingsFromAssembly(Assembly.Load("BasicProject.NHibernateInfra.Implementation"));
persistenceModel.Configure(cfg);
// set session factory field which is to be used in tests
_sessionFactory = cfg.BuildSessionFactory();
} catch (ReflectionTypeLoadException ex) {
StringBuilder sb = new StringBuilder();
foreach (Exception exSub in ex.LoaderExceptions) {
sb.AppendLine(exSub.Message);
if (exSub is FileNotFoundException) {
FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) {
sb.AppendLine("Fusion Log:");
sb.AppendLine(exFileNotFound.FusionLog);
}
}
sb.AppendLine();
}
string errorMessage = sb.ToString();
//Display or log the error based on your application.
}
}