Commit 1253f1d
Changed files (22)
trunk
product
MyMoney
boot
container
Infrastructure
transactions2
Presentation
Model
Presenters
Views
dialogs
trunk/product/MyMoney/boot/container/registration/wire_up_the_data_access_components_into_the.cs
@@ -2,6 +2,7 @@ using MoMoney.DataAccess.db40;
using MoMoney.Infrastructure.Container;
using MoMoney.Infrastructure.transactions2;
using MoMoney.Utility.Core;
+using MoMoney.Utility.Extensions;
namespace MoMoney.boot.container.registration
{
@@ -17,7 +18,9 @@ namespace MoMoney.boot.container.registration
public void run()
{
register.singleton<ISessionContext, SessionContext>();
- register.singleton<IDatabaseConfiguration, DatabaseConfiguration>();
+ //register.singleton<IDatabaseConfiguration, DatabaseConfiguration>();
+ register.singleton<IDatabase, Database>();
+ register.singleton(() => resolve.dependency_for<IDatabase>().downcast_to<IDatabaseConfiguration>());
}
}
}
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_infrastructure_in_to_the.cs
@@ -23,7 +23,7 @@ namespace MoMoney.boot.container.registration
registry.singleton<IEventAggregator, EventAggregator>();
registry.singleton<ITimer, IntervalTimer>();
registry.singleton<IUnitOfWorkRegistry, UnitOfWorkRegistry>();
- registry.singleton<IProject, CurrentProject>();
+ registry.singleton<IProjectController, ProjectController>();
registry.transient(typeof (IRegistry<>), typeof (DefaultRegistry<>));
registry.transient(typeof (IUnitOfWorkRegistrationFactory<>), typeof (UnitOfWorkRegistrationFactory<>));
trunk/product/MyMoney/Infrastructure/transactions2/Database.cs
@@ -1,23 +1,25 @@
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using MoMoney.Domain.Core;
+using MoMoney.Presentation.Model.Projects;
namespace MoMoney.Infrastructure.transactions2
{
- public class Database : IDatabase
+ public class Database : IDatabase, IDatabaseConfiguration
{
- readonly IDatabaseConfiguration configuration;
readonly IConnectionFactory factory;
+ IFile path;
- public Database(IDatabaseConfiguration configuration, IConnectionFactory factory)
+ public Database(IConnectionFactory factory)
{
- this.configuration = configuration;
this.factory = factory;
+ path = new ApplicationFile(Path.GetTempFileName());
}
public IEnumerable<T> fetch_all<T>() where T : IEntity
{
- using (var connection = factory.open_connection_to(configuration.path_to_database()))
+ using (var connection = factory.open_connection_to(path_to_database()))
{
return connection.query<T>().ToList();
}
@@ -25,11 +27,27 @@ namespace MoMoney.Infrastructure.transactions2
public void apply(IStatement statement)
{
- using (var connection = factory.open_connection_to(configuration.path_to_database()))
+ using (var connection = factory.open_connection_to(path_to_database()))
{
statement.prepare(connection);
connection.commit();
}
}
+
+ public IFile path_to_database()
+ {
+ return path;
+ }
+
+ public void open(IFile file)
+ {
+ path = new ApplicationFile(Path.GetTempFileName());
+ file.copy_to(path.path);
+ }
+
+ public void copy_to(string new_path)
+ {
+ path.copy_to(new_path);
+ }
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/transactions2/DatabaseConfiguration.cs
@@ -8,32 +8,38 @@ namespace MoMoney.Infrastructure.transactions2
public interface IDatabaseConfiguration
{
IFile path_to_database();
- void change_path_to(IFile file);
+ void open(IFile file);
+ void copy_to(string path);
}
- public class DatabaseConfiguration : IDatabaseConfiguration, IEventSubscriber<NewProjectOpened>
- {
- IFile path;
+ //public class DatabaseConfiguration : IDatabaseConfiguration, IEventSubscriber<NewProjectOpened>
+ //{
+ // IFile path;
- public DatabaseConfiguration()
- {
- path = new ApplicationFile(Path.GetTempFileName());
- }
+ // public DatabaseConfiguration()
+ // {
+ // path = new ApplicationFile(Path.GetTempFileName());
+ // }
- public IFile path_to_database()
- {
- return path;
- }
+ // public IFile path_to_database()
+ // {
+ // return path;
+ // }
- public void change_path_to(IFile file)
- {
- path = new ApplicationFile(Path.GetTempFileName());
- file.copy_to(path.path);
- }
+ // public void open(IFile file)
+ // {
+ // path = new ApplicationFile(Path.GetTempFileName());
+ // file.copy_to(path.path);
+ // }
- public void notify(NewProjectOpened message)
- {
- path = new ApplicationFile(Path.GetTempFileName());
- }
- }
+ // public void copy_to(string new_path)
+ // {
+ // path.copy_to(new_path);
+ // }
+
+ // public void notify(NewProjectOpened message)
+ // {
+ // path = new ApplicationFile(Path.GetTempFileName());
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/CloseProjectCommand.cs
@@ -10,10 +10,10 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
public class CloseProjectCommand : ICloseCommand
{
- readonly IProject project;
+ readonly IProjectController project;
readonly ISaveChangesCommand command;
- public CloseProjectCommand(IProject project, ISaveChangesCommand command)
+ public CloseProjectCommand(IProjectController project, ISaveChangesCommand command)
{
this.command = command;
this.project = project;
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/NewCommand.cs
@@ -9,10 +9,10 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
public class NewCommand : INewCommand
{
- readonly IProject current_project;
+ readonly IProjectController current_project;
readonly ISaveChangesCommand save_changes_command;
- public NewCommand(IProject current_project, ISaveChangesCommand save_changes_command)
+ public NewCommand(IProjectController current_project, ISaveChangesCommand save_changes_command)
{
this.current_project = current_project;
this.save_changes_command = save_changes_command;
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/NewCommandSpecs.cs
@@ -12,12 +12,12 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
{
context c = () =>
{
- current_project = the_dependency<IProject>();
+ current_project = the_dependency<IProjectController>();
command = the_dependency<ILoadPresentationModulesCommand>();
save_changes_command = the_dependency<ISaveChangesCommand>();
};
- protected static IProject current_project;
+ protected static IProjectController current_project;
protected static ILoadPresentationModulesCommand command;
protected static ISaveChangesCommand save_changes_command;
}
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/OpenCommand.cs
@@ -11,10 +11,10 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
public class OpenCommand : IOpenCommand
{
readonly ISelectFileToOpenDialog view;
- readonly IProject project;
+ readonly IProjectController project;
readonly ISaveChangesCommand save_changes_command;
- public OpenCommand(ISelectFileToOpenDialog view, IProject project, ISaveChangesCommand save_changes_command)
+ public OpenCommand(ISelectFileToOpenDialog view, IProjectController project, ISaveChangesCommand save_changes_command)
{
this.view = view;
this.save_changes_command = save_changes_command;
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/OpenCommandSpecs.cs
@@ -13,11 +13,11 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
context c = () =>
{
view = the_dependency<ISelectFileToOpenDialog>();
- project = the_dependency<IProject>();
+ project = the_dependency<IProjectController>();
save_changes_command = the_dependency<ISaveChangesCommand>();
};
- protected static IProject project;
+ protected static IProjectController project;
protected static ISelectFileToOpenDialog view;
protected static ISaveChangesCommand save_changes_command;
}
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/SaveAsCommand.cs
@@ -10,10 +10,10 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
public class SaveAsCommand : ISaveAsCommand
{
- readonly IProject current_project;
+ readonly IProjectController current_project;
readonly ISelectFileToSaveToDialog view;
- public SaveAsCommand(ISelectFileToSaveToDialog view, IProject current_project)
+ public SaveAsCommand(ISelectFileToSaveToDialog view, IProjectController current_project)
{
this.view = view;
this.current_project = current_project;
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/SaveAsCommandSpecs.cs
@@ -14,7 +14,7 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
context c = () =>
{
- current_project = an<IProject>();
+ current_project = an<IProjectController>();
view = an<ISelectFileToSaveToDialog>();
new_path = "blah_blah";
@@ -28,7 +28,7 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
return new SaveAsCommand(view, current_project);
}
- static IProject current_project;
+ static IProjectController current_project;
static Projects.ApplicationFile new_path;
static ISelectFileToSaveToDialog view;
}
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/SaveChangesCommand.cs
@@ -26,12 +26,12 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
public class SaveChangesCommand : ISaveChangesCommand, ISaveChangesPresenter
{
- readonly IProject current_project;
+ readonly IProjectController current_project;
readonly ISaveChangesView view;
readonly ISaveAsCommand save_as_command;
ISaveChangesCallback callback;
- public SaveChangesCommand(IProject current_project, ISaveChangesView view, ISaveAsCommand save_as_command)
+ public SaveChangesCommand(IProjectController current_project, ISaveChangesView view, ISaveAsCommand save_as_command)
{
this.current_project = current_project;
this.save_as_command = save_as_command;
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/SaveCommand.cs
@@ -9,10 +9,10 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
public class SaveCommand : ISaveCommand
{
- readonly IProject the_current_project;
+ readonly IProjectController the_current_project;
readonly ISaveAsCommand save_as_command;
- public SaveCommand(IProject current_project, ISaveAsCommand save_as_command)
+ public SaveCommand(IProjectController current_project, ISaveAsCommand save_as_command)
{
the_current_project = current_project;
this.save_as_command = save_as_command;
@@ -20,14 +20,8 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
public void run()
{
- if (the_current_project.has_been_saved_at_least_once())
- {
- the_current_project.save_changes();
- }
- else
- {
- save_as_command.run();
- }
+ if (the_current_project.has_been_saved_at_least_once()) the_current_project.save_changes();
+ else save_as_command.run();
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Model/Menu/File/Commands/SaveCommandSpecs.cs
@@ -16,11 +16,11 @@ namespace MoMoney.Presentation.Model.Menu.File.Commands
context c = () =>
{
- current_project = an<IProject>();
+ current_project = an<IProjectController>();
save_as_command = an<ISaveAsCommand>();
};
protected static ISaveAsCommand save_as_command;
- protected static IProject current_project;
+ protected static IProjectController current_project;
}
public class when_saving_the_current_project_that_has_not_been_saved_yet : behaves_like_the_save_command
trunk/product/MyMoney/Presentation/Model/Menu/File/FileMenu.cs
@@ -12,9 +12,9 @@ namespace MoMoney.Presentation.Model.Menu.File
public class FileMenu : SubMenu, IFileMenu
{
- readonly IProject project;
+ readonly IProjectController project;
- public FileMenu(IProject project)
+ public FileMenu(IProjectController project)
{
this.project = project;
}
trunk/product/MyMoney/Presentation/Model/Projects/CurrentProject.cs โ trunk/product/MyMoney/Presentation/Model/Projects/ProjectController.cs
@@ -5,7 +5,7 @@ using MoMoney.Utility.Extensions;
namespace MoMoney.Presentation.Model.Projects
{
- public interface IProject
+ public interface IProjectController
{
string name();
void start_new_project();
@@ -18,15 +18,15 @@ namespace MoMoney.Presentation.Model.Projects
bool is_open();
}
- public class CurrentProject : IProject, IEventSubscriber<UnsavedChangesEvent>
+ public class ProjectController : IProjectController, IEventSubscriber<UnsavedChangesEvent>
{
readonly IEventAggregator broker;
- IDatabaseConfiguration configuration;
+ readonly IDatabaseConfiguration configuration;
IFile current_file;
bool is_project_open = false;
bool unsaved_changes = false;
- public CurrentProject(IEventAggregator broker, IDatabaseConfiguration configuration)
+ public ProjectController(IEventAggregator broker, IDatabaseConfiguration configuration)
{
this.broker = broker;
this.configuration = configuration;
@@ -50,7 +50,7 @@ namespace MoMoney.Presentation.Model.Projects
{
if (!file.does_the_file_exist()) return;
close_project();
- configuration.change_path_to(file);
+ configuration.open(file);
current_file = file;
is_project_open = true;
broker.publish(new NewProjectOpened(name()));
@@ -59,7 +59,7 @@ namespace MoMoney.Presentation.Model.Projects
public void save_changes()
{
ensure_that_a_path_to_save_to_has_been_specified();
- configuration.path_to_database().copy_to(current_file.path);
+ configuration.copy_to(current_file.path);
unsaved_changes = false;
broker.publish<SavedChangesEvent>();
}
trunk/product/MyMoney/Presentation/Model/Projects/CurrentProjectSpecs.cs โ trunk/product/MyMoney/Presentation/Model/Projects/ProjectControllerSpecs.cs
@@ -1,29 +1,31 @@
using System;
using developwithpassion.bdd.contexts;
-using MoMoney.DataAccess.db40;
using MoMoney.Infrastructure.eventing;
-using MoMoney.Infrastructure.transactions;
+using MoMoney.Infrastructure.transactions2;
using MoMoney.Presentation.Model.messages;
using MoMoney.Testing;
using MoMoney.Testing.MetaData;
using MoMoney.Testing.spechelpers.contexts;
using MoMoney.Testing.spechelpers.core;
+using MoMoney.Utility.Extensions;
namespace MoMoney.Presentation.Model.Projects
{
- [Concern(typeof (CurrentProject))]
- public abstract class behaves_like_a_project : concerns_for<IProject, CurrentProject>
+ public class ProjectControllerSpecs
+ {
+ }
+
+ [Concern(typeof (ProjectController))]
+ public abstract class behaves_like_a_project : concerns_for<IProjectController, ProjectController>
{
context c = () =>
{
broker = the_dependency<IEventAggregator>();
- registry = the_dependency<IUnitOfWorkRegistry>();
- context = the_dependency<ISessionContext>();
+ configuration = the_dependency<IDatabaseConfiguration>();
};
protected static IEventAggregator broker;
- protected static IUnitOfWorkRegistry registry;
- protected static ISessionContext context;
+ protected static IDatabaseConfiguration configuration;
}
public class when_saving_the_current_project : behaves_like_a_project
@@ -59,13 +61,12 @@ 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.copy_to("blah"));
context c = () =>
{
original_file = an<IFile>();
new_file = an<IFile>();
- database_file = an<IFile>();
when_the(new_file).is_told_to(x => x.path).it_will_return("blah");
};
@@ -76,7 +77,6 @@ namespace MoMoney.Presentation.Model.Projects
};
static IFile original_file;
- static IFile database_file;
static IFile new_file;
}
@@ -147,14 +147,14 @@ namespace MoMoney.Presentation.Model.Projects
{
it should_return_true = () => result.should_be_true();
- context c = () =>
+ context c = () => { };
+
+ because b = () =>
{
- an<IFile>();
- registry.is_told_to(x => x.has_changes_to_commit()).it_will_return(true);
+ sut.downcast_to<ProjectController>().notify(new UnsavedChangesEvent());
+ result = sut.has_unsaved_changes();
};
- because b = () => { result = sut.has_unsaved_changes(); };
-
static bool result;
}
trunk/product/MyMoney/Presentation/Presenters/Shell/TitleBarPresenter.cs
@@ -17,10 +17,10 @@ namespace MoMoney.Presentation.Presenters.Shell
public class TitleBarPresenter : ITitleBarPresenter
{
readonly ITitleBar view;
- readonly IProject project;
+ readonly IProjectController project;
readonly IEventAggregator broker;
- public TitleBarPresenter(ITitleBar view, IProject project, IEventAggregator broker)
+ public TitleBarPresenter(ITitleBar view, IProjectController project, IEventAggregator broker)
{
this.view = view;
this.project = project;
trunk/product/MyMoney/Presentation/Presenters/Shell/TitleBarPresenterSpecs.cs
@@ -14,14 +14,14 @@ namespace MoMoney.Presentation.Presenters.Shell
{
context c = () =>
{
- project = the_dependency<IProject>();
+ project = the_dependency<IProjectController>();
view = the_dependency<ITitleBar>();
broker = the_dependency<IEventAggregator>();
};
protected static ITitleBar view;
protected static IEventAggregator broker;
- protected static IProject project;
+ protected static IProjectController project;
}
public class when_initializing_the_title_bar_for_the_first_time : behaves_like_a_title_bar_presenter
trunk/product/MyMoney/Presentation/Presenters/Shell/ToolBarPresenter.cs
@@ -17,9 +17,9 @@ namespace MoMoney.Presentation.Presenters.Shell
public class ToolBarPresenter : IToolbarPresenter
{
readonly IShell shell;
- readonly IProject project;
+ readonly IProjectController project;
- public ToolBarPresenter(IShell shell, IProject project)
+ public ToolBarPresenter(IShell shell, IProjectController project)
{
this.shell = shell;
this.project = project;
trunk/product/MyMoney/Presentation/Views/dialogs/select_file_to_save_to_dialog.cs โ trunk/product/MyMoney/Presentation/Views/dialogs/SelectFileToSaveToDialog.cs
@@ -8,11 +8,11 @@ namespace MoMoney.Presentation.Views.dialogs
IFile tell_me_the_path_to_the_file();
}
- public class select_file_to_save_to_dialog : ISelectFileToSaveToDialog
+ public class SelectFileToSaveToDialog : ISelectFileToSaveToDialog
{
private readonly FileDialog dialog;
- public select_file_to_save_to_dialog()
+ public SelectFileToSaveToDialog()
{
dialog = new SaveFileDialog {Filter = "My Money Files (*.mo)|*.mo"};
}
trunk/product/MyMoney/MyMoney.csproj
@@ -373,7 +373,7 @@
<Compile Include="Presentation\Model\Navigation\branches\AddNewIncomeBranch.cs" />
<Compile Include="Presentation\Model\Navigation\branches\view_all_bills_branch.cs" />
<Compile Include="Presentation\Model\Navigation\branches\view_all_bills_report_branch.cs" />
- <Compile Include="Presentation\Model\Projects\CurrentProject.cs" />
+ <Compile Include="Presentation\Model\Projects\ProjectController.cs" />
<Compile Include="Presentation\Core\PresenterRegistry.cs" />
<Compile Include="Presentation\Model\Menu\create.cs" />
<Compile Include="Presentation\Model\Menu\File\Commands\ExitCommand.cs" />
@@ -393,7 +393,7 @@
<Compile Include="Presentation\Model\Navigation\TreeBranch.cs" />
<Compile Include="Presentation\Model\Navigation\tree_branch_specs.cs" />
<Compile Include="Presentation\Model\Navigation\TreeViewToRootNodeMapper.cs" />
- <Compile Include="Presentation\Model\Projects\CurrentProjectSpecs.cs" />
+ <Compile Include="Presentation\Model\Projects\ProjectControllerSpecs.cs" />
<Compile Include="Presentation\Model\Projects\file.cs" />
<Compile Include="Presentation\Model\Projects\file_not_specified_exception.cs" />
<Compile Include="Presentation\Model\reporting\IReport.cs" />
@@ -517,7 +517,7 @@
<Compile Include="Presentation\Views\core\IDockedContentView.cs" />
<Compile Include="Presentation\Views\core\IView.cs" />
<Compile Include="Presentation\Views\dialogs\select_file_to_open_dialog.cs" />
- <Compile Include="Presentation\Views\dialogs\select_file_to_save_to_dialog.cs" />
+ <Compile Include="Presentation\Views\dialogs\SelectFileToSaveToDialog.cs" />
<Compile Include="Presentation\Views\income\AddNewIncomeView.cs">
<SubType>Form</SubType>
</Compile>