Stefan Sedich's Blog

try { Stefan.Code(); } catch(BadCodeException) { NotLikely(); }

  • So I Created Another Utils Library

    Thought it was time I start my own Utils library (why not everyone else seems to have one), I have things like a UnitOfWork implementation, base Repository class, and plan to add more things as I go.

    This is still a work in progress and I would appreciate any feedback out there, in the meantime I will continue my work on it.

    You can find the project on GitHub @ http://github.com/stefansedich/YetAnotherUtilsLib


    Cheers
    Stefan

  • In Memory SQLite + Unit Test + FluentNHibernate

    UPDATE:

    I have forked fluent NH here: http://github.com/stefansedich/fluent-nhibernate, and added a change so we can just use:

    .Database(SQLiteConfiguration.Standard.InMemory().ShowSql())

    By default the InMemory() helper will now add the pooling support, I sent a push request, so hopefully this hits trunk. Not sure if I was being silly but I do not see a need where you would not pool in memory SQLite anyway.

    ----------------------------------------------------------

    Just playing around with FNH for the first time, getting my unit tests running proved to be a pain, did a Google and had no luck finding a solution to my problem.

    A quick play using the fluent config I found a way to get it working, my full session factory setup is below:

    public ISessionFactory GetSessionFactory() { return Fluently.Configure() .Database(SQLiteConfiguration.Standard.InMemory() .ConnectionString("Data Source=:memory:;Version=3;New=True;Pooling=True;Max Pool Size=1;")) .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(CustomerRepository).Assembly)) .ExposeConfiguration(config => new SchemaExport(config).Create(true, true)) .BuildSessionFactory(); }

    The key was to set the Pooling=True;Max PoolSize=1; in my config, looking at fluent NH the .InMemory() shortcut seems to not set these:

    public SQLiteConfiguration InMemory() { Raw("connection.release_mode", "on_close"); return ConnectionString(c => c .Is("Data Source=:memory:;Version=3;New=True;")); }

    Guess it would be great if it did, but for the time being I will just do it manually.


    Cheers
    Stefan

  • NHibernate Session Management using FluentNhibernate and Castle Windsor

    Time for my first post in a while, thought I would post on session management using Castle Windsor.

    I found this good post, http://blog.stevehorn.cc/2009/03/fluent-nhibernate-configured-via.html and I have basically converted it to use Castle for IoC instead.

    The Windsor config that will work is below:

    var container = new WindsorContainer();
    container.AddFacility(); // This adds support to be able to use the UsingFactoryMethod.

    container.Register(Component.For().ImplementedBy().LifeStyle.Singleton);
    container.Register(Component.For().UsingFactoryMethod(x => x.Resolve() .GetSessionFactory() .OpenSession()).LifeStyle.PerWebRequest);

    The only other addition that is needed for Windsor is to add the PerWebRequest module to your Web.config file in the httpModules section:

    <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" />

    And you are done, nice and simple NHibernate Session management using a Windsor container.



    Cheers Stefan

  • Mammoth VPS launches Backups, DNS Management and more!!!

    Yesterday we launched a bunch of new features over at MammothVPS,


    - All VPS' now have an on-site, off-server backup facility available to them. By default all customers will have 1 free weekly backup made available to them, and should you wish to you can purchase more slots which are available in daily, weekly and monthly schedules.

    - DNS hosting has been made available and will be free for all customers. You can find the new interface in your mPanel.

    - A cleanup of the menu system has been done to make it easier to navigate around both the site and mPanel.

    - You will find new sections on site, we now have more information about our services and have included things like a Knowledge Base, which will provide information on howto setup various applications on your VPS.

    - Added the ability to change the kernel your VPS is running on.


    So head on over to MammothVPS and check it out.


  • Unit Testing ASP.NET? ASP.NET unit testing has never been this easy


    Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.

    Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.

    The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

    Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

    The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.

    Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

    Go ahead, click the following link for more information on how to get your free license.