Permalink
Browse files

Recrete database on every run, do some select as well as inserts in t…

…est publisher
  • Loading branch information...
1 parent ab483cd commit e7280e8622c94b6bb3afb337bc45d22c85779cd0 @seif committed Mar 13, 2012
Showing with 9 additions and 37 deletions.
  1. +9 −37 src/TestPublisher/Program.cs
@@ -19,19 +19,19 @@ static void Main(string[] args)
{
Console.WriteLine("Press enter to start publishing");
Console.ReadLine();
- Publisher.Start();
-
+
var config = new Configuration();
config.Configure("nh.sqlserver.config");
config.SessionFactoryName("Test session factory");
config.AddAssembly(typeof(Dog).Assembly);
- new SchemaUpdate(config).Execute(false, true);
+ new SchemaExport(config).Execute(false, false, true);
+ new SchemaExport(config).Execute(false, true, false);
using(var sessionFactory = config.BuildSessionFactory())
{
Stopwatch sw = new Stopwatch();
-
+ Publisher.Start();
sw.Start();
InsertData(sessionFactory);
TimeSpan elapsedWithLogging = sw.Elapsed;
@@ -40,21 +40,16 @@ static void Main(string[] args)
Publisher.Shutdown();
TimeSpan shutdownTime = sw.Elapsed;
- sw.Restart();
- InsertData(sessionFactory);
- TimeSpan elapsedWithoutLogging = sw.Elapsed;
-
- Console.WriteLine("Inserting data without logging took: {0}", elapsedWithoutLogging);
- Console.WriteLine("Inserting data with logging took: {0}", elapsedWithLogging);
+ Console.WriteLine("Completed in: {0}", elapsedWithLogging);
Console.WriteLine("Shutdown complete in {0}, press any key to exit", shutdownTime);
}
Console.ReadLine();
}
private static void InsertData(ISessionFactory sessionFactory)
{
- Task[] tasks = new Task[50];
- for (int i = 0; i < 50; i++)
+ Task[] tasks = new Task[500];
+ for (int i = 0; i < 500; i++)
{
tasks[i] = new Task(
() =>
@@ -95,31 +90,8 @@ private static void InsertData(ISessionFactory sessionFactory)
{
using (var tx = session.BeginTransaction())
{
- session.Save(
- new Lizard()
- {
- SerialNumber = "11111",
- Description = "Saving lizard to get a new logger requested"
- });
-
- var dog = new Dog
- {
- BirthDate = DateTime.Now.AddYears(-1),
- BodyWeight = 10,
- Description = "Some dog",
- SerialNumber = "98765"
- };
- var puppy = new Dog
- {
- BirthDate = DateTime.Now,
- BodyWeight = 2,
- Description = "Some pup",
- SerialNumber = "9875"
- };
- dog.Children = new List<Animal>();
- dog.Children.Add(puppy);
- puppy.Mother = dog;
-
+ session.CreateCriteria<Dog>().List();
+ session.QueryOver<Animal>().Where(a => a.BodyWeight > 0);
tx.Commit();
}
}

0 comments on commit e7280e8

Please sign in to comment.