Commit 18face4

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-03-16 18:09:53
fixed the unhandled error presenter.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@79 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent d09c36c
Changed files (5)
trunk
product
MyMoney
trunk/product/MyMoney/DataAccess/db40/SessionContext.cs
@@ -10,6 +10,7 @@ namespace MoMoney.DataAccess.db40
         void start_session_for(IFile file);
         ISession current_session();
         void close_session_to(IFile file);
+        void commit_current_session();
     }
 
     [Singleton]
@@ -45,5 +46,10 @@ namespace MoMoney.DataAccess.db40
             sessions[file].Dispose();
             sessions.Remove(file);
         }
+
+        public void commit_current_session()
+        {
+            current_session().commit();
+        }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Model/Projects/CurrentProject.cs
@@ -28,11 +28,11 @@ namespace MoMoney.Presentation.Model.Projects
         IFile current_file;
         bool is_project_open = false;
 
-        public CurrentProject(IEventAggregator broker, IUnitOfWorkRegistry registry, ISessionContext _context)
+        public CurrentProject(IEventAggregator broker, IUnitOfWorkRegistry registry, ISessionContext context)
         {
             this.broker = broker;
             this.registry = registry;
-            this.context = _context;
+            this.context = context;
         }
 
         public string name()
@@ -63,7 +63,7 @@ namespace MoMoney.Presentation.Model.Projects
             ensure_that_a_path_to_save_to_has_been_specified();
             registry.commit_all();
             registry.Dispose();
-            context.current_session().commit();
+            context.commit_current_session();
             broker.publish<saved_changes_event>();
         }
 
trunk/product/MyMoney/Presentation/Model/Projects/CurrentProjectSpecs.cs
@@ -2,6 +2,7 @@ using System;
 using developwithpassion.bdd.contexts;
 using MoMoney.DataAccess.db40;
 using MoMoney.Infrastructure.eventing;
+using MoMoney.Infrastructure.transactions;
 using MoMoney.Presentation.Model.messages;
 using MoMoney.Testing;
 using MoMoney.Testing.MetaData;
@@ -15,12 +16,14 @@ namespace MoMoney.Presentation.Model.Projects
     {
         context c = () =>
                         {
-                            configuration = the_dependency<IDatabaseConfiguration>();
                             broker = the_dependency<IEventAggregator>();
+                            registry = the_dependency<IUnitOfWorkRegistry>();
+                            context = the_dependency<ISessionContext>();
                         };
 
-        protected static IDatabaseConfiguration configuration;
-        protected static IEventAggregator broker;
+        static protected IEventAggregator broker;
+        static protected IUnitOfWorkRegistry registry;
+        static protected ISessionContext context;
     }
 
     public class when_saving_the_current_project : behaves_like_a_project
@@ -31,9 +34,7 @@ namespace MoMoney.Presentation.Model.Projects
                         {
                             file_to_update = an<IFile>();
                             current_file = an<IFile>();
-
-                            when_the(configuration).is_told_to(x => x.path_to_the_database()). it_will_return(current_file);
-                            when_the(file_to_update).is_told_to(x => x.does_the_file_exist()). it_will_return(true);
+                            when_the(file_to_update).is_told_to(x => x.does_the_file_exist()).it_will_return(true);
                         };
 
         because b = () =>
@@ -58,7 +59,7 @@ namespace MoMoney.Presentation.Model.Projects
 
     public class when_specifying_a_new_path_to_save_an_opened_project_to : behaves_like_a_project
     {
-        it should_save_the_current_database_to_the_new_path = () => configuration.was_told_to(x => x.change_path_to(new_file));
+        //it should_save_the_current_database_to_the_new_path = () => configuration.was_told_to(x => x.change_path_to(new_file));
 
         context c = () =>
                         {
@@ -149,13 +150,13 @@ namespace MoMoney.Presentation.Model.Projects
         context c = () =>
                         {
                             file = an<IFile>();
-                            message = new unsaved_changes_event();
+                            registry.is_told_to(x => x.has_changes_to_commit()).it_will_return(true);
                         };
 
         because b = () =>
                         {
-                            sut.start_new_project();
-                            sut.save_project_to(file);
+                            //sut.start_new_project();
+                            //sut.save_project_to(file);
                             //sut.notify(message);
                             result = sut.has_unsaved_changes();
                         };
trunk/product/MyMoney/Presentation/Presenters/Shell/UnhandledErrorPresenter.cs
@@ -1,5 +1,4 @@
 using MoMoney.Infrastructure.eventing;
-using MoMoney.Infrastructure.Extensions;
 using MoMoney.Presentation.Core;
 using MoMoney.Presentation.Model.messages;
 using MoMoney.Presentation.Presenters.Commands;
@@ -28,6 +27,7 @@ namespace MoMoney.Presentation.Presenters.Shell
 
         public void run()
         {
+            view.attach_to(this);
             broker.subscribe_to(this);
         }
 
@@ -38,7 +38,6 @@ namespace MoMoney.Presentation.Presenters.Shell
 
         public void restart_application()
         {
-            this.log().debug("restart the application");
             restart.run();
         }
     }
trunk/product/MyMoney/Presentation/Views/core/ApplicationWindow.cs
@@ -32,7 +32,7 @@ namespace MoMoney.Presentation.Views.core
             return this;
         }
 
-        public void on_ui_thread(Action action)
+        protected void on_ui_thread(Action action)
         {
             if (InvokeRequired)
             {