Commit 3656322

mo khan <mo@mokhan.ca>
2009-05-11 16:18:19
added specs that went missing from svn to git move
1 parent 4bc392b
product/Gorilla.Commons.Infrastructure/Cloning/BinarySerializerSpecs.cs
@@ -6,31 +6,31 @@ using MbUnit.Framework;
 
 namespace Gorilla.Commons.Infrastructure.Cloning
 {
-    [Concern(typeof(BinarySerializer<TestItem>))]
-    public abstract class behaves_like_serializer : concerns_for<ISerializer<TestItem>>
+    [Concern(typeof (BinarySerializer<TestItem>))]
+    public abstract class when_a_file_is_specified_to_serialize_an_item_to : concerns_for<ISerializer<TestItem>, BinarySerializer<TestItem>>
     {
         public override ISerializer<TestItem> create_sut()
         {
             return new BinarySerializer<TestItem>(file_name);
         }
 
-        context c = () => { file_name = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Serialized.dat"); };
+        context c = () => { file_name = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "serialized.dat"); };
 
         after_each_observation aeo = () => { if (File.Exists(file_name)) File.Delete(file_name); };
 
-        protected static string file_name;
+        static protected string file_name;
     }
 
-    [Concern(typeof(BinarySerializer<TestItem>))]
-    public class when_serializing_an_item : behaves_like_serializer
+    [Concern(typeof (BinarySerializer<TestItem>))]
+    public class when_serializing_an_item : when_a_file_is_specified_to_serialize_an_item_to
     {
         it should_serialize_the_item_to_a_file = () => FileAssert.Exists(file_name);
 
         because b = () => sut.serialize(new TestItem(string.Empty));
     }
 
-    [Concern(typeof(BinarySerializer<TestItem>))]
-    public class when_deserializing_an_item : behaves_like_serializer
+    [Concern(typeof (BinarySerializer<TestItem>))]
+    public class when_deserializing_an_item : when_a_file_is_specified_to_serialize_an_item_to
     {
         it should_be_able_to_deserialize_from_a_serialized_file = () => result.should_be_equal_to(original);
 
product/Gorilla.Commons.Infrastructure/Container/DependencyResolutionException.cs
@@ -5,8 +5,8 @@ namespace Gorilla.Commons.Infrastructure.Container
 {
     public class DependencyResolutionException<T> : Exception
     {
-        public DependencyResolutionException(Exception innerException)
-            : base("Could not resolve {0}".formatted_using(typeof (T).FullName), innerException)
+        public DependencyResolutionException(Exception inner_exception)
+            : base("Could not resolve {0}".formatted_using(typeof (T).FullName), inner_exception)
         {
         }
     }
product/Gorilla.Commons.Infrastructure/Proxies/IInterceptor.cs
@@ -2,6 +2,6 @@ namespace Gorilla.Commons.Infrastructure.Proxies
 {
     public interface IInterceptor
     {
-        void Intercept(IInvocation invocation);
+        void intercept(IInvocation invocation);
     }
 }
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Proxies/IInvocation.cs
@@ -4,9 +4,9 @@ namespace Gorilla.Commons.Infrastructure.Proxies
 {
     public interface IInvocation
     {
-        void Proceed();
-        object[] Arguments { get; }
-        MethodInfo Method { get; }
-        object ReturnValue { get; set; }
+        void proceed();
+        object[] arguments { get; }
+        MethodInfo method { get; }
+        object return_value { get; set; }
     }
 }
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Proxies/MethodCallInvocation.cs
@@ -16,27 +16,27 @@ namespace Gorilla.Commons.Infrastructure.Proxies
             this.call = call;
             this.target = target;
             this.interceptors = new Stack<IInterceptor>(interceptors);
-            Arguments = call.Properties["__Args"].downcast_to<object[]>();
-            Method = call.MethodBase.downcast_to<MethodInfo>();
+            arguments = call.Properties["__Args"].downcast_to<object[]>();
+            method = call.MethodBase.downcast_to<MethodInfo>();
         }
 
-        public object[] Arguments { get; set; }
+        public object[] arguments { get; set; }
 
-        public MethodInfo Method { get; set; }
+        public MethodInfo method { get; set; }
 
-        public object ReturnValue { get; set; }
+        public object return_value { get; set; }
 
-        public void Proceed()
+        public void proceed()
         {
             if (interceptors.Count > 0)
             {
-                interceptors.Pop().Intercept(this);
+                interceptors.Pop().intercept(this);
                 return;
             }
 
             try
             {
-                ReturnValue = call.MethodBase.Invoke(target, Arguments);
+                return_value = call.MethodBase.Invoke(target, arguments);
             }
             catch (TargetInvocationException e)
             {
product/Gorilla.Commons.Infrastructure/Proxies/ProxyFactory.cs
@@ -2,9 +2,9 @@ namespace Gorilla.Commons.Infrastructure.Proxies
 {
     static public class ProxyFactory
     {
-        static public T Create<T>(T target, params IInterceptor[] interceptors)
+        static public T create<T>(T target, params IInterceptor[] interceptors)
         {
-            return new RemotingProxyFactory<T>(target, interceptors).CreateProxy();
+            return new RemotingProxyFactory<T>(target, interceptors).create_proxy();
         }
     }
 }
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Proxies/ProxyFactorySpecs.cs
@@ -17,7 +17,7 @@ namespace Gorilla.Commons.Infrastructure.Proxies
                         };
 
         because b =
-            () => { some_celebrity = ProxyFactory.Create<IPerson>(marshal_mathers, interceptors); };
+            () => { some_celebrity = ProxyFactory.create<IPerson>(marshal_mathers, interceptors); };
 
         it should_all_each_interceptor_to_intercept_the_invocation =
             () => some_celebrity.what_is_your_name().should_be_equal_to("slim shady");
@@ -49,10 +49,10 @@ namespace Gorilla.Commons.Infrastructure.Proxies
 
     public class MyNameIsSlimShadyInterceptor : IInterceptor
     {
-        public void Intercept(IInvocation invocation)
+        public void intercept(IInvocation invocation)
         {
-            invocation.Proceed();
-            invocation.ReturnValue = "slim shady";
+            invocation.proceed();
+            invocation.return_value = "slim shady";
         }
     }
 }
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Proxies/RemotingProxyFactory.cs
@@ -22,13 +22,13 @@ namespace Gorilla.Commons.Infrastructure.Proxies
             {
                 var call = message.downcast_to<IMethodCallMessage>();
                 var invocation = new MethodCallInvocation<T>(interceptors, call, target);
-                invocation.Proceed();
-                return ReturnValue(invocation.ReturnValue, invocation.Arguments, call);
+                invocation.proceed();
+                return return_value(invocation.return_value, invocation.arguments, call);
             }
             return null;
         }
 
-        IMessage ReturnValue(object return_value, object[] out_parameters, IMethodCallMessage call)
+        IMessage return_value(object return_value, object[] out_parameters, IMethodCallMessage call)
         {
             return new ReturnMessage(return_value,
                                      out_parameters,
@@ -36,7 +36,7 @@ namespace Gorilla.Commons.Infrastructure.Proxies
                                      call.LogicalCallContext, call);
         }
 
-        public T CreateProxy()
+        public T create_proxy()
         {
             return GetTransparentProxy().downcast_to<T>();
         }
product/Gorilla.Commons.Infrastructure/Registries/DefaultRegistry.cs
@@ -6,7 +6,7 @@ namespace Gorilla.Commons.Infrastructure.Registries
 {
     public class DefaultRegistry<T> : IRegistry<T>
     {
-        private readonly IDependencyRegistry registry;
+        readonly IDependencyRegistry registry;
 
         public DefaultRegistry(IDependencyRegistry registry)
         {
product/Gorilla.Commons.Infrastructure/Threading/ISynchronizationContext.cs
@@ -1,8 +0,0 @@
-using Gorilla.Commons.Utility.Core;
-
-namespace Gorilla.Commons.Infrastructure.Threading
-{
-    public interface ISynchronizationContext : IParameterizedCommand<ICommand>
-    {
-    }
-}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Threading/SynchronizedContext.cs
@@ -3,6 +3,10 @@ using Gorilla.Commons.Utility.Core;
 
 namespace Gorilla.Commons.Infrastructure.Threading
 {
+    public interface ISynchronizationContext : IParameterizedCommand<ICommand>
+    {
+    }
+
     public class SynchronizedContext : ISynchronizationContext
     {
         readonly SynchronizationContext context;
product/Gorilla.Commons.Infrastructure/Threading/Synchronizer.cs
@@ -25,7 +25,7 @@ namespace Gorilla.Commons.Infrastructure.Threading
         public IAsyncResult BeginInvoke(Delegate method, object[] args)
         {
             var result = new WorkItem(null, method, args);
-            worker_thread.QueueWorkItem(result);
+            worker_thread.queue_work_item(result);
             return result;
         }
 
@@ -46,7 +46,7 @@ namespace Gorilla.Commons.Infrastructure.Threading
 
         public void Dispose()
         {
-            worker_thread.Kill();
+            worker_thread.kill();
         }
 
         class WorkerThread
@@ -66,14 +66,14 @@ namespace Gorilla.Commons.Infrastructure.Threading
                 end_loop_mutex = new Mutex();
                 item_added = new AutoResetEvent(false);
                 work_item_queue = new Queue();
-                CreateThread(true);
+                create_thread(true);
             }
 
-            internal void QueueWorkItem(WorkItem workItem)
+            internal void queue_work_item(WorkItem work_item)
             {
                 lock (work_item_queue.SyncRoot)
                 {
-                    work_item_queue.Enqueue(workItem);
+                    work_item_queue.Enqueue(work_item);
                     item_added.Set();
                 }
             }
@@ -96,29 +96,29 @@ namespace Gorilla.Commons.Infrastructure.Threading
                 }
             }
 
-            Thread CreateThread(bool autoStart)
+            Thread create_thread(bool auto_start)
             {
                 if (thread != null)
                 {
                     Debug.Assert(false);
                     return thread;
                 }
-                thread = new Thread(Run) {Name = "Synchronizer Worker Thread"};
-                if (autoStart)
+                thread = new Thread(run) {Name = "Synchronizer Worker Thread"};
+                if (auto_start)
                 {
                     thread.Start();
                 }
                 return thread;
             }
 
-            void Start()
+            void start()
             {
                 Debug.Assert(thread != null);
                 Debug.Assert(thread.IsAlive == false);
                 thread.Start();
             }
 
-            bool QueueEmpty
+            bool queue_empty
             {
                 get
                 {
@@ -135,7 +135,7 @@ namespace Gorilla.Commons.Infrastructure.Threading
 
             WorkItem GetNext()
             {
-                if (QueueEmpty)
+                if (queue_empty)
                 {
                     return null;
                 }
@@ -145,11 +145,11 @@ namespace Gorilla.Commons.Infrastructure.Threading
                 }
             }
 
-            void Run()
+            void run()
             {
                 while (EndLoop == false)
                 {
-                    while (QueueEmpty == false)
+                    while (queue_empty == false)
                     {
                         if (EndLoop)
                         {
@@ -162,7 +162,7 @@ namespace Gorilla.Commons.Infrastructure.Threading
                 }
             }
 
-            public void Kill()
+            public void kill()
             {
                 //Kill is called on client thread - must use cached thread object
                 Debug.Assert(thread != null);
product/Gorilla.Commons.Infrastructure/Threading/WorkItem.cs
@@ -6,31 +6,31 @@ namespace Gorilla.Commons.Infrastructure.Threading
     [Serializable]
     internal class WorkItem : IAsyncResult
     {
-        readonly object[] m_Args;
-        readonly object m_AsyncState;
-        bool m_Completed;
-        readonly Delegate m_Method;
-        readonly ManualResetEvent m_Event;
-        object m_MethodReturnedValue;
+        readonly object[] args;
+        readonly object async_state;
+        bool completed;
+        readonly Delegate method;
+        readonly ManualResetEvent reset_event;
+        object returned_value;
 
         internal WorkItem(object async_state, Delegate method, object[] args)
         {
-            m_AsyncState = async_state;
-            m_Method = method;
-            m_Args = args;
-            m_Event = new ManualResetEvent(false);
-            m_Completed = false;
+            this.async_state = async_state;
+            this.method = method;
+            this.args = args;
+            reset_event = new ManualResetEvent(false);
+            completed = false;
         }
 
         //IAsyncResult properties 
         object IAsyncResult.AsyncState
         {
-            get { return m_AsyncState; }
+            get { return async_state; }
         }
 
         WaitHandle IAsyncResult.AsyncWaitHandle
         {
-            get { return m_Event; }
+            get { return reset_event; }
         }
 
         bool IAsyncResult.CompletedSynchronously
@@ -49,14 +49,14 @@ namespace Gorilla.Commons.Infrastructure.Threading
             {
                 lock (this)
                 {
-                    return m_Completed;
+                    return completed;
                 }
             }
             set
             {
                 lock (this)
                 {
-                    m_Completed = value;
+                    completed = value;
                 }
             }
         }
@@ -64,9 +64,9 @@ namespace Gorilla.Commons.Infrastructure.Threading
         //This method is called on the worker thread to execute the method
         internal void CallBack()
         {
-            MethodReturnedValue = m_Method.DynamicInvoke(m_Args);
+            MethodReturnedValue = method.DynamicInvoke(args);
             //Method is done. Signal the world
-            m_Event.Set();
+            reset_event.Set();
             Completed = true;
         }
 
@@ -74,18 +74,18 @@ namespace Gorilla.Commons.Infrastructure.Threading
         {
             get
             {
-                object methodReturnedValue;
+                object method_returned_value;
                 lock (this)
                 {
-                    methodReturnedValue = m_MethodReturnedValue;
+                    method_returned_value = returned_value;
                 }
-                return methodReturnedValue;
+                return method_returned_value;
             }
             set
             {
                 lock (this)
                 {
-                    m_MethodReturnedValue = value;
+                    returned_value = value;
                 }
             }
         }
product/Gorilla.Commons.Infrastructure/Transactions/ChangeTracker.cs
@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using Gorilla.Commons.Infrastructure.Logging;
 using Gorilla.Commons.Utility.Core;
 using Gorilla.Commons.Utility.Extensions;
 
@@ -24,7 +23,6 @@ namespace Gorilla.Commons.Infrastructure.Transactions
 
         public void register(T entity)
         {
-            this.log().debug("registered: {0}", entity);
             items.Add(mapper.map_from(entity));
         }
 
@@ -35,14 +33,12 @@ namespace Gorilla.Commons.Infrastructure.Transactions
 
         public void commit_to(IDatabase database)
         {
-            items.each(x => this.log().debug("committing: {0}", x.current));
             items.each(x => commit(x, database));
             to_be_deleted.each(x => database.apply(registry.prepare_command_for(x)));
         }
 
         public bool is_dirty()
         {
-            this.log().debug("is change tracker dirty? {0}",items.Count(x => x.has_changes()) );
             return items.Count(x => x.has_changes()) > 0 || to_be_deleted.Count > 0;
         }
 
product/Gorilla.Commons.Infrastructure/Transactions/CurrentThread.cs
@@ -6,9 +6,14 @@ namespace Gorilla.Commons.Infrastructure.Transactions
     {
         public T provide_slot_for<T>() where T : class, new()
         {
-            var slot = Thread.GetNamedDataSlot(GetType().FullName + typeof (T).FullName);
+            var slot = Thread.GetNamedDataSlot(create_key_for<T>());
             if (null == Thread.GetData(slot)) Thread.SetData(slot, new T());
             return (T) Thread.GetData(slot);
         }
+
+        string create_key_for<T>()
+        {
+            return Thread.CurrentThread.ManagedThreadId + GetType().FullName + typeof (T).FullName;
+        }
     }
 }
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Transactions/SessionSpecs.cs
@@ -27,8 +27,6 @@ namespace Gorilla.Commons.Infrastructure.Transactions
     {
         it should_add_the_entity_to_the_identity_map = () => map.was_told_to(x => x.add(guid, entity));
 
-        //it should_add_the_item_to_the_current_transaction = () => transaction.was_told_to(x => x.add_transient(entity));
-
         context c = () =>
                         {
                             guid = Guid.NewGuid();
@@ -93,8 +91,7 @@ namespace Gorilla.Commons.Infrastructure.Transactions
                             when_the(cached_item).is_told_to(x => x.id).it_will_return(id);
                             when_the(database_item).is_told_to(x => x.id).it_will_return(id);
                             when_the(uncached_item).is_told_to(x => x.id).it_will_return(id_of_the_uncached_item);
-                            when_the(transaction).is_told_to(x => x.create_for<ITestEntity>()).it_will_return(
-                                identity_map);
+                            when_the(transaction).is_told_to(x => x.create_for<ITestEntity>()).it_will_return( identity_map);
                             when_the(identity_map).is_told_to(x => x.contains_an_item_for(id)).it_will_return(true);
                             when_the(identity_map).is_told_to(x => x.all()).it_will_return(cached_item);
                             when_the(database).is_told_to(x => x.fetch_all<ITestEntity>())
@@ -153,8 +150,6 @@ namespace Gorilla.Commons.Infrastructure.Transactions
     {
         it should_remove_that_item_from_the_cache = () => map.was_told_to(x => x.evict(id));
 
-        //it should_mark_the_item_for_deletion_when_the_transaction_is_committed = () => transaction.was_told_to(x => x.mark_for_deletion(entity));
-
         context c = () =>
                         {
                             id = Guid.NewGuid();
product/Gorilla.Commons.Infrastructure/Transactions/SingletonScopedStorage.cs
@@ -4,7 +4,7 @@ namespace Gorilla.Commons.Infrastructure.Transactions
 {
     public class SingletonScopedStorage : IScopedStorage
     {
-        static public readonly IDictionary storage = new Hashtable();
+        static readonly IDictionary storage = new Hashtable();
 
         public IDictionary provide_storage()
         {
product/Gorilla.Commons.Infrastructure/Transactions/StatementRegistry.cs
@@ -1,5 +1,4 @@
 using System;
-using Gorilla.Commons.Infrastructure.Logging;
 using Gorilla.Commons.Utility.Core;
 
 namespace Gorilla.Commons.Infrastructure.Transactions
@@ -29,7 +28,6 @@ namespace Gorilla.Commons.Infrastructure.Transactions
         public void prepare(IDatabaseConnection connection)
         {
             connection.store(entity);
-            this.log().debug("saving: {0}", entity);
         }
     }
 
product/Gorilla.Commons.Infrastructure/Transactions/Transaction.cs
@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using Gorilla.Commons.Infrastructure.Logging;
 using Gorilla.Commons.Utility.Core;
 using Gorilla.Commons.Utility.Extensions;
 
@@ -46,8 +45,6 @@ namespace Gorilla.Commons.Infrastructure.Transactions
 
         public bool is_dirty()
         {
-            this.log().debug("changes trackers {0}", change_trackers.Count);
-            this.log().debug("is transaction dirty? {0}", change_trackers.Values.Count(x => x.is_dirty()));
             return change_trackers.Values.Count(x => x.is_dirty()) > 0;
         }
 
product/Gorilla.Commons.Infrastructure/Transactions/TransactionSpecs.cs
@@ -14,12 +14,10 @@ namespace Gorilla.Commons.Infrastructure.Transactions
     {
         context c = () =>
                         {
-                            registry = the_dependency<IStatementRegistry>();
                             database = the_dependency<IDatabase>();
                             factory = the_dependency<IChangeTrackerFactory>();
                         };
 
-        static protected IStatementRegistry registry;
         static protected IDatabase database;
         static protected IChangeTrackerFactory factory;
     }
@@ -37,7 +35,8 @@ namespace Gorilla.Commons.Infrastructure.Transactions
     [Concern(typeof (Transaction))]
     public class when_committing_a_transaction_and_an_item_in_the_identity_map_has_changed : behaves_like_transaction
     {
-        it should_commit_the_changes_to_that_item = () => tracker.was_told_to<IChangeTracker<IMovie>>(x => x.commit_to(database));
+        it should_commit_the_changes_to_that_item =
+            () => tracker.was_told_to<IChangeTracker<IMovie>>(x => x.commit_to(database));
 
         context c = () =>
                         {
product/Gorilla.Commons.Infrastructure/Transactions/UnitOfWork.cs
@@ -1,5 +1,4 @@
 using System;
-using Gorilla.Commons.Infrastructure.Logging;
 
 namespace Gorilla.Commons.Infrastructure.Transactions
 {
@@ -29,7 +28,6 @@ namespace Gorilla.Commons.Infrastructure.Transactions
 
         public bool is_dirty()
         {
-            this.log().debug("is session dirty? {0}", session.is_dirty());
             return session.is_dirty();
         }
 
product/Gorilla.Commons.Infrastructure/Transactions/UnitOfWorkFactorySpecs.cs
@@ -0,0 +1,77 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Infrastructure.Transactions
+{
+    public class UnitOfWorkFactorySpecs
+    {
+    }
+
+    [Concern(typeof (UnitOfWorkFactory))]
+    public abstract class concerns_for_unit_of_work_factory : concerns_for<IUnitOfWorkFactory, UnitOfWorkFactory>
+    {
+        context c = () =>
+                        {
+                            session_context = the_dependency<IContext>();
+                            factory = the_dependency<ISessionFactory>();
+                            key = the_dependency<IKey<ISession>>();
+                        };
+
+        static protected IContext session_context;
+        static protected ISessionFactory factory;
+        static protected IKey<ISession> key;
+    }
+
+    [Concern(typeof (UnitOfWorkFactory))]
+    public class when_a_unit_of_work_has_not_been_started : concerns_for_unit_of_work_factory
+    {
+        context c = () => { when_the(session_context).is_told_to(x => x.contains(key)).it_will_return(false); };
+    }
+
+    [Concern(typeof (UnitOfWorkFactory))]
+    public class when_a_unit_of_work_has_been_started : concerns_for_unit_of_work_factory
+    {
+        context c = () => { when_the(session_context).is_told_to(x => x.contains(key)).it_will_return(true); };
+    }
+
+    [Concern(typeof (UnitOfWorkFactory))]
+    public class when_creating_a_new_unit_of_work : when_a_unit_of_work_has_not_been_started
+    {
+        context c = () =>
+                        {
+                            session = an<ISession>();
+                            when_the(factory).is_told_to(x => x.create()).it_will_return(session);
+                        };
+
+        because b = () => { result = sut.create(); };
+
+        it should_create_a_new_unit_of_work = () => factory.was_told_to(x => x.create());
+
+        it should_add_the_session_to_the_current_context = () => session_context.was_told_to(x => x.add(key, session));
+
+        it should_return_a_brand_new_unit_of_work = () =>
+                                                        {
+                                                            result.should_not_be_null();
+                                                            result.should_be_an_instance_of<UnitOfWork>();
+                                                        };
+
+        static IUnitOfWork result;
+        static ISession session;
+    }
+
+    [Concern(typeof (UnitOfWorkFactory))]
+    public class when_attempting_to_create_a_new_unit_of_work : when_a_unit_of_work_has_been_started
+    {
+        because b = () => { result = sut.create(); };
+
+        it should_not_create_a_new_unit_of_work = () => factory.was_not_told_to(x => x.create());
+
+        it should_return_an_empty_unit_of_work = () =>
+                                                     {
+                                                         result.should_not_be_null();
+                                                         result.should_be_an_instance_of<EmptyUnitOfWork>();
+                                                     };
+
+        static IUnitOfWork result;
+    }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Transactions/UnitOfWorkSpecs.cs
@@ -0,0 +1,66 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Infrastructure.Transactions
+{
+    public class UnitOfWorkSpecs
+    {
+    }
+
+    [Concern(typeof (UnitOfWork))]
+    public abstract class behaves_like_unit_of_work : concerns_for<IUnitOfWork, UnitOfWork>
+    {
+        context c = () =>
+                        {
+                            session_context = the_dependency<IContext>();
+                            session = the_dependency<ISession>();
+                            key = the_dependency<IKey<ISession>>();
+                        };
+
+        static protected IContext session_context;
+        static protected ISession session;
+        static protected IKey<ISession> key;
+    }
+
+    [Concern(typeof (UnitOfWork))]
+    public abstract class when_a_unit_of_work_has_unsaved_changes : behaves_like_unit_of_work
+    {
+        context c = () => when_the(session).is_told_to(x => x.is_dirty()).it_will_return(true);
+    }
+
+    [Concern(typeof (UnitOfWork))]
+    public abstract class when_a_unit_of_work_has_no_changes : behaves_like_unit_of_work
+    {
+        context c = () => when_the(session).is_told_to(x => x.is_dirty()).it_will_return(false);
+    }
+
+    [Concern(typeof (UnitOfWork))]
+    public class when_checking_if_a_unit_of_work_has_any_unsaved_changes : when_a_unit_of_work_has_unsaved_changes
+    {
+        it should_return_true = () => result.should_be_true();
+        because b = () => { result = sut.is_dirty(); };
+        static bool result;
+    }
+
+    [Concern(typeof (UnitOfWork))]
+    public class when_commiting_a_unit_of_work : when_a_unit_of_work_has_unsaved_changes
+    {
+        it should_flush_the_current_session = () => session.was_told_to(x => x.flush());
+        because b = () => sut.commit();
+    }
+
+    [Concern(typeof (UnitOfWork))]
+    public class when_attempting_to_commit_a_unit_of_work : when_a_unit_of_work_has_no_changes
+    {
+        it should_not_flush_the_session = () => session.was_not_told_to(x => x.flush());
+        because b = () => sut.commit();
+    }
+
+    [Concern(typeof (UnitOfWork))]
+    public class when_disposing_of_a_unit_of_work : behaves_like_unit_of_work
+    {
+        it should_dispose_the_session = () => session.was_told_to(x => x.Dispose());
+        it should_remove_the_session_from_the_current_context = () => session_context.was_told_to(x => x.remove(key));
+        because b = () => sut.Dispose();
+    }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Gorilla.Commons.Infrastructure.csproj
@@ -111,7 +111,6 @@
     <Compile Include="Threading\ICommandProcessor.cs" />
     <Compile Include="Threading\IntervalTimer.cs" />
     <Compile Include="Threading\IntervalTimerSpecs.cs" />
-    <Compile Include="Threading\ISynchronizationContext.cs" />
     <Compile Include="Threading\ITimerClient.cs" />
     <Compile Include="Threading\IWorkerThread.cs" />
     <Compile Include="Threading\SynchronizationContextFactory.cs" />
@@ -166,6 +165,8 @@
     <Compile Include="Transactions\TypedKey.cs" />
     <Compile Include="Transactions\UnitOfWork.cs" />
     <Compile Include="Transactions\UnitOfWorkFactory.cs" />
+    <Compile Include="Transactions\UnitOfWorkFactorySpecs.cs" />
+    <Compile Include="Transactions\UnitOfWorkSpecs.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj">
product/Gorilla.Commons.Infrastructure/ProcessQueryCommand.cs
@@ -22,7 +22,7 @@ namespace Gorilla.Commons.Infrastructure
         public void run(ICallback<T> callback)
         {
             var dto = query.fetch();
-            factory.create().run(new ActionCommand((Action) (()=> callback.run(dto))));
+            factory.create().run(new ActionCommand((Action) (() => callback.run(dto))));
         }
     }
 }
\ No newline at end of file
product/Gorilla.Commons.Infrastructure.ThirdParty/Castle/Windsor/WindsorDependencyRegistry.cs
@@ -20,7 +20,8 @@ namespace Gorilla.Commons.Infrastructure.Castle.Windsor
 
         public Interface get_a<Interface>()
         {
-            return underlying_container.Kernel.Resolve<Interface>();
+            return underlying_container.Resolve<Interface>();
+            //return underlying_container.Kernel.Resolve<Interface>();
         }
 
         public IEnumerable<Interface> all_the<Interface>()
product/Gorilla.Commons.Utility/Core/ActionCommand.cs
@@ -9,7 +9,6 @@ namespace Gorilla.Commons.Utility.Core
 
         public ActionCommand(Expression<Action> action) : this(action.Compile())
         {
-
         }
 
         public ActionCommand(Action action)
product/Gorilla.Commons.Windows.Forms/Helpers/BitmapRegion.cs
@@ -7,7 +7,7 @@ namespace Gorilla.Commons.Windows.Forms.Helpers
     public static class BitmapRegion
     {
         /// <summary>
-        /// Create and apply the region on the supplied control
+        /// create and apply the region on the supplied control
         /// </summary>
         /// <param name="control">The Control object to apply the region to</param>
         /// <param name="bitmap">The Bitmap object to create the region from</param>
@@ -76,7 +76,7 @@ namespace Gorilla.Commons.Windows.Forms.Helpers
         /// <returns>Calculated graphics path</returns>
         static GraphicsPath CalculateControlGraphicsPath(Bitmap bitmap)
         {
-            // Create GraphicsPath for our bitmap calculation
+            // create GraphicsPath for our bitmap calculation
             var graphicsPath = new GraphicsPath();
 
             // Use the top left pixel as our transparent color
@@ -101,7 +101,7 @@ namespace Gorilla.Commons.Windows.Forms.Helpers
                         // Opaque pixel found, mark current position
                         colOpaquePixel = col;
 
-                        // Create another variable to set the current pixel position
+                        // create another variable to set the current pixel position
                         var colNext = col;
 
                         // Starting from current found opaque pixel, search for anymore opaque pixels