Commit e602071
Changed files (14)
trunk
product
MyMoney
boot
container
registration
Presentation
Presenters
Tasks
trunk/product/MyMoney/boot/container/registration/wire_up_the_essential_services_into_the.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.Deployment.Application;
using System.Threading;
using System.Windows.Forms;
using MoMoney.Infrastructure.Container;
@@ -34,6 +35,7 @@ namespace MoMoney.boot.container.registration
return SynchronizationContext.Current;
});
registration.singleton<AsyncOperation>(() => AsyncOperationManager.CreateOperation(null));
+ registration.singleton<ApplicationDeployment>( () => ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment : null);
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/updates/CheckForUpdatesPresenter.cs
@@ -18,16 +18,21 @@ namespace MoMoney.Presentation.Presenters.updates
public class CheckForUpdatesPresenter : ICheckForUpdatesPresenter
{
readonly ICheckForUpdatesView view;
- readonly IUpdateTasks tasks;
readonly IRestartCommand command;
readonly IDisplayNextAvailableVersion display_version_command;
+ readonly IDownloadTheLatestVersion download_the_latest;
+ readonly ICancelUpdate cancel_requested_update;
- public CheckForUpdatesPresenter(ICheckForUpdatesView view, IUpdateTasks tasks, IRestartCommand command,
- IDisplayNextAvailableVersion display_version_command)
+ public CheckForUpdatesPresenter(ICheckForUpdatesView view,
+ IRestartCommand command,
+ IDisplayNextAvailableVersion display_version_command,
+ IDownloadTheLatestVersion download_the_latest,
+ ICancelUpdate cancel_requested_update)
{
this.view = view;
+ this.cancel_requested_update = cancel_requested_update;
+ this.download_the_latest = download_the_latest;
this.display_version_command = display_version_command;
- this.tasks = tasks;
this.command = command;
}
@@ -40,12 +45,12 @@ namespace MoMoney.Presentation.Presenters.updates
public void begin_update()
{
- tasks.grab_the_latest_version(this);
+ download_the_latest.run(this);
}
public void cancel_update()
{
- tasks.stop_updating();
+ cancel_requested_update.run();
view.close();
}
trunk/product/MyMoney/Presentation/Presenters/updates/CheckForUpdatesPresenterSpecs.cs
@@ -1,5 +1,4 @@
using developwithpassion.bdd.contexts;
-using MoMoney.Presentation.Model.updates;
using MoMoney.Presentation.Presenters.Commands;
using MoMoney.Presentation.Views.updates;
using MoMoney.Tasks.infrastructure.updating;
@@ -16,13 +15,17 @@ namespace MoMoney.Presentation.Presenters.updates
context c = () =>
{
view = the_dependency<ICheckForUpdatesView>();
- tasks = the_dependency<IUpdateTasks>();
command = the_dependency<IRestartCommand>();
+ download_the_latest = the_dependency<IDownloadTheLatestVersion>();
+ next_version = the_dependency<IDisplayNextAvailableVersion>();
+ cancel_update = the_dependency<ICancelUpdate>();
};
- static protected ICheckForUpdatesView view;
- static protected IUpdateTasks tasks;
- static protected IRestartCommand command;
+ protected static ICheckForUpdatesView view;
+ protected static IRestartCommand command;
+ protected static IDownloadTheLatestVersion download_the_latest;
+ protected static IDisplayNextAvailableVersion next_version;
+ protected static ICancelUpdate cancel_update;
}
public class when_attempting_to_check_for_updates : behaves_like_check_for_updates_presenter
@@ -32,21 +35,15 @@ namespace MoMoney.Presentation.Presenters.updates
it should_tell_the_view_to_display_the_information_on_the_current_version_of_the_application =
() => view.was_told_to(x => x.display());
- context c = () =>
- {
- version = an<ApplicationVersion>();
- when_the(tasks).is_told_to(x => x.current_application_version()).it_will_return(version);
- };
+ it should_go_and_find_out_what_the_latest_version_is = () => next_version.was_told_to(x => x.run(view));
because b = () => sut.run();
-
- static ApplicationVersion version;
}
public class when_initiating_an_update_and_one_is_available : behaves_like_check_for_updates_presenter
{
it should_start_downloading_the_latest_version_of_the_application =
- () => tasks.was_told_to(x => x.grab_the_latest_version(sut));
+ () => download_the_latest.was_told_to(x => x.run(sut));
because b = () => sut.begin_update();
}
@@ -67,7 +64,7 @@ namespace MoMoney.Presentation.Presenters.updates
public class when_an_update_is_cancelled : behaves_like_check_for_updates_presenter
{
- it should_stop_downloading_the_latest_update = () => tasks.was_told_to(x => x.stop_updating());
+ it should_stop_downloading_the_latest_update = () => cancel_update.was_told_to(x => x.run());
because b = () => sut.cancel_update();
}
trunk/product/MyMoney/Tasks/infrastructure/updating/CommandFactory.cs โ trunk/product/MyMoney/Tasks/infrastructure/core/CommandFactory.cs
@@ -1,6 +1,6 @@
using MoMoney.Utility.Core;
-namespace MoMoney.Tasks.infrastructure.updating
+namespace MoMoney.Tasks.infrastructure.core
{
public interface ICommandFactory
{
trunk/product/MyMoney/Tasks/infrastructure/core/ICallbackCommand.cs
@@ -0,0 +1,8 @@
+using MoMoney.Utility.Core;
+
+namespace MoMoney.Tasks.infrastructure.core
+{
+ public interface ICallbackCommand<T> : IParameterizedCommand<ICallback<T>>
+ {
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Tasks/infrastructure/updating/ProcessQueryCommand.cs โ trunk/product/MyMoney/Tasks/infrastructure/core/ProcessQueryCommand.cs
@@ -1,6 +1,6 @@
using MoMoney.Utility.Core;
-namespace MoMoney.Tasks.infrastructure.updating
+namespace MoMoney.Tasks.infrastructure.core
{
public interface IProcessQueryCommand<T> : IParameterizedCommand<ICallback<T>>
{
@@ -15,9 +15,9 @@ namespace MoMoney.Tasks.infrastructure.updating
this.query = query;
}
- public void run(ICallback<T> item)
+ public void run(ICallback<T> callback)
{
- item.run(query.fetch());
+ callback.run(query.fetch());
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Tasks/infrastructure/updating/RunQueryCommand.cs โ trunk/product/MyMoney/Tasks/infrastructure/core/RunQueryCommand.cs
@@ -1,6 +1,6 @@
using MoMoney.Utility.Core;
-namespace MoMoney.Tasks.infrastructure.updating
+namespace MoMoney.Tasks.infrastructure.core
{
public interface IRunQueryCommand<T> : ICommand
{
trunk/product/MyMoney/Tasks/infrastructure/updating/CancelUpdate.cs
@@ -0,0 +1,25 @@
+using System.Deployment.Application;
+using MoMoney.Utility.Core;
+
+namespace MoMoney.Tasks.infrastructure.updating
+{
+ public interface ICancelUpdate : ICommand
+ {
+ }
+
+ public class CancelUpdate : ICancelUpdate
+ {
+ readonly ApplicationDeployment deployment;
+
+ public CancelUpdate(ApplicationDeployment deployment)
+ {
+ this.deployment = deployment;
+ }
+
+ public void run()
+ {
+ if (null == deployment) return;
+ deployment.UpdateAsyncCancel();
+ }
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Tasks/infrastructure/updating/CancelUpdateSpecs.cs
@@ -0,0 +1,24 @@
+using System.Deployment.Application;
+using developwithpassion.bdd.contexts;
+using MbUnit.Framework;
+using MoMoney.Testing.spechelpers.contexts;
+using MoMoney.Testing.spechelpers.core;
+
+namespace MoMoney.Tasks.infrastructure.updating
+{
+ public class CancelUpdateSpecs
+ {
+ }
+
+ [Ignore("cant mock ApplicationDeployment")]
+ public class when_cancelling_an_update_of_the_application : concerns_for<ICancelUpdate, CancelUpdate>
+ {
+ it should_stop_downloading_the_update = () => deployment.was_told_to(x => x.UpdateAsyncCancel());
+
+ context c = () => { deployment = the_dependency<ApplicationDeployment>(); };
+
+ because b = () => sut.run();
+
+ static ApplicationDeployment deployment;
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Tasks/infrastructure/updating/DisplayNextAvailableVersion.cs
@@ -1,10 +1,11 @@
using MoMoney.Infrastructure.Threading;
using MoMoney.Presentation.Model.updates;
+using MoMoney.Tasks.infrastructure.core;
using MoMoney.Utility.Core;
namespace MoMoney.Tasks.infrastructure.updating
{
- public interface IDisplayNextAvailableVersion : IParameterizedCommand<ICallback<ApplicationVersion>>
+ public interface IDisplayNextAvailableVersion : ICallbackCommand<ApplicationVersion>
{
}
@@ -14,7 +15,8 @@ namespace MoMoney.Tasks.infrastructure.updating
readonly ICommandProcessor processor;
readonly ICommandFactory factory;
- public DisplayNextAvailableVersion(IWhatIsTheAvailableVersion query, ICommandProcessor processor, ICommandFactory factory)
+ public DisplayNextAvailableVersion(IWhatIsTheAvailableVersion query, ICommandProcessor processor,
+ ICommandFactory factory)
{
this.query = query;
this.factory = factory;
trunk/product/MyMoney/Tasks/infrastructure/updating/DownloadTheLatestVersion.cs
@@ -0,0 +1,28 @@
+using System.Deployment.Application;
+using MoMoney.Domain.Core;
+using MoMoney.Tasks.infrastructure.core;
+using MoMoney.Utility.Core;
+
+namespace MoMoney.Tasks.infrastructure.updating
+{
+ public interface IDownloadTheLatestVersion : ICallbackCommand<Percent>
+ {
+ }
+
+ public class DownloadTheLatestVersion : IDownloadTheLatestVersion
+ {
+ readonly ApplicationDeployment deployment;
+
+ public DownloadTheLatestVersion(ApplicationDeployment deployment)
+ {
+ this.deployment = deployment;
+ }
+
+ public void run(ICallback<Percent> callback)
+ {
+ deployment.UpdateProgressChanged += (o, e) => callback.run(new Percent(e.BytesCompleted, e.BytesTotal));
+ deployment.UpdateCompleted += (sender, args) => callback.run(100);
+ deployment.UpdateAsync();
+ }
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Tasks/infrastructure/updating/UpdateTasks.cs
@@ -1,65 +0,0 @@
-using System.Deployment.Application;
-using System.Threading;
-using MoMoney.Domain.Core;
-using MoMoney.Presentation.Model.updates;
-using MoMoney.Utility.Core;
-
-namespace MoMoney.Tasks.infrastructure.updating
-{
- public interface IUpdateTasks
- {
- ApplicationVersion current_application_version();
- void grab_the_latest_version(ICallback<Percent> callback);
- void stop_updating();
- }
-
- public class UpdateTasks : IUpdateTasks
- {
- readonly ApplicationDeployment deployment;
-
- public UpdateTasks()
- {
- if (ApplicationDeployment.IsNetworkDeployed)
- {
- deployment = ApplicationDeployment.CurrentDeployment;
- }
- }
-
- public ApplicationVersion current_application_version()
- {
- if (null == deployment)
- {
- Thread.Sleep(5000);
- return new ApplicationVersion {updates_available = false,};
- }
-
- var update = deployment.CheckForDetailedUpdate();
- return new ApplicationVersion
- {
- activation_url = deployment.ActivationUri,
- current = deployment.CurrentVersion,
- data_directory = deployment.DataDirectory,
- updates_available = update.IsUpdateRequired || update.UpdateAvailable,
- last_checked_for_updates = deployment.TimeOfLastUpdateCheck,
- application_name = deployment.UpdatedApplicationFullName,
- deployment_url = deployment.UpdateLocation,
- available_version = update.AvailableVersion,
- size_of_update_in_bytes = update.UpdateSizeBytes,
- };
- }
-
- public void grab_the_latest_version(ICallback<Percent> callback)
- {
- deployment.UpdateProgressChanged += (o, e) => callback.run(new Percent(e.BytesCompleted, e.BytesTotal));
- deployment.UpdateCompleted += (sender, args) => callback.run(100);
- deployment.UpdateAsync();
- }
-
- public void stop_updating()
- {
- if (null == deployment) return;
-
- deployment.UpdateAsyncCancel();
- }
- }
-}
\ No newline at end of file
trunk/product/MyMoney/Tasks/infrastructure/updating/WhatIsTheAvailableVersion.cs
@@ -1,3 +1,5 @@
+using System.Deployment.Application;
+using System.Threading;
using MoMoney.Presentation.Model.updates;
using MoMoney.Utility.Core;
@@ -9,16 +11,34 @@ namespace MoMoney.Tasks.infrastructure.updating
public class WhatIsTheAvailableVersion : IWhatIsTheAvailableVersion
{
- readonly IUpdateTasks tasks;
+ readonly ApplicationDeployment deployment;
- public WhatIsTheAvailableVersion(IUpdateTasks tasks)
+ public WhatIsTheAvailableVersion(ApplicationDeployment deployment)
{
- this.tasks = tasks;
+ this.deployment = deployment;
}
public ApplicationVersion fetch()
{
- return tasks.current_application_version();
+ if (null == deployment)
+ {
+ Thread.Sleep(5000);
+ return new ApplicationVersion {updates_available = false,};
+ }
+
+ var update = deployment.CheckForDetailedUpdate();
+ return new ApplicationVersion
+ {
+ activation_url = deployment.ActivationUri,
+ current = deployment.CurrentVersion,
+ data_directory = deployment.DataDirectory,
+ updates_available = update.IsUpdateRequired || update.UpdateAvailable,
+ last_checked_for_updates = deployment.TimeOfLastUpdateCheck,
+ application_name = deployment.UpdatedApplicationFullName,
+ deployment_url = deployment.UpdateLocation,
+ available_version = update.AvailableVersion,
+ size_of_update_in_bytes = update.UpdateSizeBytes,
+ };
}
}
}
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -559,12 +559,15 @@
<Compile Include="Tasks\application\BillingTasks.cs" />
<Compile Include="Tasks\application\CustomerTasks.cs" />
<Compile Include="Tasks\application\IncomeTasks.cs" />
+ <Compile Include="Tasks\infrastructure\core\ICallbackCommand.cs" />
<Compile Include="Tasks\infrastructure\LogFileTasks.cs" />
- <Compile Include="Tasks\infrastructure\updating\CommandFactory.cs" />
+ <Compile Include="Tasks\infrastructure\core\CommandFactory.cs" />
+ <Compile Include="Tasks\infrastructure\updating\CancelUpdate.cs" />
+ <Compile Include="Tasks\infrastructure\updating\CancelUpdateSpecs.cs" />
<Compile Include="Tasks\infrastructure\updating\DisplayNextAvailableVersion.cs" />
- <Compile Include="Tasks\infrastructure\updating\ProcessQueryCommand.cs" />
- <Compile Include="Tasks\infrastructure\updating\RunQueryCommand.cs" />
- <Compile Include="Tasks\infrastructure\updating\UpdateTasks.cs" />
+ <Compile Include="Tasks\infrastructure\core\ProcessQueryCommand.cs" />
+ <Compile Include="Tasks\infrastructure\core\RunQueryCommand.cs" />
+ <Compile Include="Tasks\infrastructure\updating\DownloadTheLatestVersion.cs" />
<Compile Include="Tasks\infrastructure\updating\WhatIsTheAvailableVersion.cs" />
<Compile Include="Testing\MetaData\IntegrationAttribute.cs" />
<Compile Include="Testing\spechelpers\contexts\concerns.cs" />