using System; using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; using Portoa.NHibernate; namespace VideoGameQuotes.Api.Tests.NHibernate { [TestFixture, Ignore] 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_initial_data() { 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(session).Save(admin); tx.Commit(); } 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(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(); } } } }