2011-02-09 19:28:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using NHibernate.Cfg;
|
2011-02-09 00:05:32 +00:00
|
|
|
|
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]
|
2011-02-09 19:28:33 +00:00
|
|
|
|
public void Create_initial_data() {
|
2011-02-09 03:41:35 +00:00
|
|
|
|
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 19:28:33 +00:00
|
|
|
|
|
|
|
|
|
var nes = new System { Abbreviation = "NES", Name = "Nintendo Entertainment System", ReleaseDate = new DateTime(1985, 10, 18) };
|
|
|
|
|
var snes = new System { Abbreviation = "SNES", Name = "Super Nintendo Entertainment System", ReleaseDate = new DateTime(1991, 8, 23) };
|
|
|
|
|
var genny = new System { Abbreviation = "Genesis", Name = "Sega Genesis", ReleaseDate = new DateTime(1989, 10, 14) };
|
|
|
|
|
var ps = new System { Abbreviation = "PS", Name = "PlayStation", ReleaseDate = new DateTime(1995, 9, 9) };
|
|
|
|
|
var ps2 = new System { Abbreviation = "PS2", Name = "PlayStation 2", ReleaseDate = new DateTime(2000, 3, 4) };
|
|
|
|
|
var xbox = new System { Abbreviation = "Xbox", Name = "Xbox", ReleaseDate = new DateTime(2002, 2, 22) };
|
|
|
|
|
var n64 = new System { Abbreviation = "N64", Name = "Nintendo 64", ReleaseDate = new DateTime(1996, 9, 29) };
|
|
|
|
|
var gcn = new System { Abbreviation = "GCN", Name = "Nintendo GameCube", ReleaseDate = new DateTime(2001, 11, 18) };
|
|
|
|
|
var dc = new System { Abbreviation = "DC", Name = "Dreamcast", ReleaseDate = new DateTime(1999, 9, 9) };
|
|
|
|
|
var wii = new System { Abbreviation = "Wii", Name = "Wii", ReleaseDate = new DateTime(2006, 11, 19) };
|
|
|
|
|
var xbox360 = new System { Abbreviation = "360", Name = "Xbox 360", ReleaseDate = new DateTime(2005, 11, 16) };
|
|
|
|
|
var ps3 = new System { Abbreviation = "PS3", Name = "PlayStation 3", ReleaseDate = new DateTime(2006, 11, 17) };
|
|
|
|
|
var pc = new System { Abbreviation = "PC", Name = "Personal Computer", ReleaseDate = new DateTime(1980, 1, 1) };
|
|
|
|
|
|
|
|
|
|
var gb = new System { Abbreviation = "GB", Name = "Game Boy", ReleaseDate = new DateTime(1989, 7, 31) };
|
|
|
|
|
var gbc = new System { Abbreviation = "GBC", Name = "Game Boy Color", ReleaseDate = new DateTime(1998, 11, 18) };
|
|
|
|
|
var gba = new System { Abbreviation = "GBA", Name = "Game Boy Advance", ReleaseDate = new DateTime(2001, 6, 11) };
|
|
|
|
|
var nds = new System { Abbreviation = "NES", Name = "Nintendo Entertainment System", ReleaseDate = new DateTime(1985, 10, 18) };
|
|
|
|
|
var psp = new System { Abbreviation = "PSP", Name = "PlayStation Portable", ReleaseDate = new DateTime(2005, 3, 24) };
|
|
|
|
|
|
|
|
|
|
using (var tx = session.BeginTransaction()) {
|
|
|
|
|
var repo = new NHibernateRepository<System>(session);
|
|
|
|
|
repo.Save(nes);
|
|
|
|
|
repo.Save(snes);
|
|
|
|
|
repo.Save(genny);
|
|
|
|
|
repo.Save(ps);
|
|
|
|
|
repo.Save(ps2);
|
|
|
|
|
repo.Save(xbox);
|
|
|
|
|
repo.Save(n64);
|
|
|
|
|
repo.Save(gcn);
|
|
|
|
|
repo.Save(dc);
|
|
|
|
|
repo.Save(wii);
|
|
|
|
|
repo.Save(xbox360);
|
|
|
|
|
repo.Save(ps3);
|
|
|
|
|
repo.Save(pc);
|
|
|
|
|
repo.Save(gb);
|
|
|
|
|
repo.Save(gbc);
|
|
|
|
|
repo.Save(gba);
|
|
|
|
|
repo.Save(nds);
|
|
|
|
|
repo.Save(psp);
|
|
|
|
|
tx.Commit();
|
|
|
|
|
}
|
2011-02-09 00:05:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|