vgquotes/Tests/VideoGameQuotes.Api.Tests/NHibernate/SchemaExporter.cs

41 lines
1.0 KiB
C#
Raw Normal View History

2011-02-09 00:05:32 +00:00
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;
using Portoa.NHibernate;
2011-02-09 00:05:32 +00:00
namespace VideoGameQuotes.Api.Tests.NHibernate {
[TestFixture, Ignore]
2011-02-09 00:05:32 +00:00
public class SchemaExporter {
[Test]
public void Export_schema() {
new SchemaExport(GetConfig())
.SetDelimiter(";")
.SetOutputFile(@"c:\users\tmont\code\VideoGameQuotes\Tests\VideoGameQuotes.Api.Tests\NHibernate\schema.sql")
.Execute(false, true, false);
}
private Configuration GetConfig() {
return new Configuration().Configure(GetType().Assembly, GetType().Namespace + ".hibernate.cfg.xml");
}
[Test]
public void Create_admin() {
var config = GetConfig();
var admin = new User {
Username = "admin",
Group = UserGroup.Admin
};
admin.ChangePassword("password");
var session = config.BuildSessionFactory().OpenSession();
using (var tx = session.BeginTransaction()) {
new NHibernateRepository<User>(session).Save(admin);
tx.Commit();
}
2011-02-09 00:05:32 +00:00
}
}
}