2011-02-09 00:05:32 +00:00
|
|
|
|
using NHibernate.Cfg;
|
|
|
|
|
using NHibernate.Tool.hbm2ddl;
|
|
|
|
|
using NUnit.Framework;
|
2011-02-09 03:41:35 +00:00
|
|
|
|
using Portoa.NHibernate;
|
2011-02-09 00:05:32 +00:00
|
|
|
|
|
|
|
|
|
namespace VideoGameQuotes.Api.Tests.NHibernate {
|
2011-02-09 03:41:35 +00:00
|
|
|
|
[TestFixture, Ignore]
|
2011-02-09 00:05:32 +00:00
|
|
|
|
public class SchemaExporter {
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Export_schema() {
|
2011-02-09 03:41:35 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|