Commit 4d18e5b
Changed files (15)
product
desktop.ui
bootstrappers
presenters
Properties
infrastructure
specs
unit
ui
presenters
specifications
product/desktop.ui/bootstrappers/Bootstrapper.cs
@@ -12,6 +12,7 @@ using solidware.financials.service.handlers;
using solidware.financials.service.orm;
using solidware.financials.windows.ui.handlers;
using solidware.financials.windows.ui.presenters;
+using solidware.financials.windows.ui.presenters.specifications;
using solidware.financials.windows.ui.views;
namespace solidware.financials.windows.ui.bootstrappers
@@ -26,7 +27,6 @@ namespace solidware.financials.windows.ui.bootstrappers
builder.Register(x => shell_window).SingleInstance();
builder.Register(x => shell_window).As<RegionManager>().SingleInstance();
- builder.RegisterType<IfFamilyMemberIsSelected>().SingleInstance();
register_needs_startup(builder);
// infrastructure
@@ -34,6 +34,7 @@ namespace solidware.financials.windows.ui.bootstrappers
builder.RegisterType<DefaultMapper>().As<Mapper>().SingleInstance();
//builder.RegisterGeneric(typeof (Mapper<,>));
builder.RegisterType<InMemoryServiceBus>().As<ServiceBus>().SingleInstance();
+ builder.RegisterGeneric(typeof(IfFamilyMemberIsSelected<>));
register_presentation_infrastructure(builder);
register_presenters(builder);
@@ -53,7 +54,6 @@ namespace solidware.financials.windows.ui.bootstrappers
{
builder.RegisterType<ComposeShell>().As<NeedStartup>();
builder.RegisterType<ConfigureMappings>().As<NeedStartup>();
-
builder.RegisterType<WireUpSubscribers>().As<NeedStartup>();
}
@@ -68,6 +68,7 @@ namespace solidware.financials.windows.ui.bootstrappers
builder.RegisterType<AsynchronousCommandProcessor>().As<CommandProcessor>().SingleInstance();
//builder.Register<SynchronousCommandProcessor>().As<CommandProcessor>().SingleInstance();
builder.RegisterType<WPFCommandBuilder>().As<UICommandBuilder>();
+ builder.RegisterType<InMemoryApplicationState>().As<ApplicationState>().SingleInstance();
}
static void register_presenters(ContainerBuilder builder)
@@ -81,9 +82,9 @@ namespace solidware.financials.windows.ui.bootstrappers
builder.RegisterType<AddFamilyMemberPresenter>();
builder.RegisterType<AddFamilyMemberPresenter.SaveCommand>();
-
builder.RegisterType<AddNewIncomeViewModel>();
builder.RegisterType<AddNewIncomeViewModel.AddIncomeCommand>();
+ builder.RegisterType<IfFamilyMemberIsSelected<AddNewIncomeViewModel>>();
builder.RegisterType<TaxSummaryPresenter>();
product/desktop.ui/bootstrappers/WireUpSubscribers.cs
@@ -1,6 +1,6 @@
-using gorilla.infrastructure.container;
+using gorilla.infrastructure.container;
using solidware.financials.infrastructure.eventing;
-using solidware.financials.windows.ui.presenters;
+using solidware.financials.windows.ui.events;
namespace solidware.financials.windows.ui.bootstrappers
{
@@ -9,7 +9,7 @@ namespace solidware.financials.windows.ui.bootstrappers
public void run()
{
var eventAggregator = Resolve.the<EventAggregator>();
- eventAggregator.subscribe(Resolve.the<IfFamilyMemberIsSelected>());
+ eventAggregator.subscribe(new AnonymousSubscriber<SelectedFamilyMember>(x => Resolve.the<ApplicationState>().PushIn(x)));
}
}
}
\ No newline at end of file
product/desktop.ui/presenters/specifications/IfFamilyMemberIsSelected.cs
@@ -0,0 +1,19 @@
+using solidware.financials.windows.ui.events;
+
+namespace solidware.financials.windows.ui.presenters.specifications
+{
+ public class IfFamilyMemberIsSelected<T> : UISpecification<T> where T : Presenter
+ {
+ ApplicationState state;
+
+ public IfFamilyMemberIsSelected(ApplicationState state)
+ {
+ this.state = state;
+ }
+
+ public override bool is_satisfied_by(T item)
+ {
+ return state.HasBeenPushedIn<SelectedFamilyMember>();
+ }
+ }
+}
\ No newline at end of file
product/desktop.ui/presenters/AddNewIncomeViewModel.cs
@@ -2,6 +2,7 @@
using solidware.financials.infrastructure;
using solidware.financials.messages;
using solidware.financials.windows.ui.events;
+using solidware.financials.windows.ui.presenters.specifications;
namespace solidware.financials.windows.ui.presenters
{
@@ -16,7 +17,7 @@ namespace solidware.financials.windows.ui.presenters
public void present()
{
- Add = builder.build<AddIncomeCommand, IfFamilyMemberIsSelected>(this);
+ Add = builder.build<AddIncomeCommand, IfFamilyMemberIsSelected<AddNewIncomeViewModel>>(this);
Cancel = builder.build<CancelCommand>(this);
}
product/desktop.ui/presenters/IfFamilyMemberIsSelected.cs
@@ -1,21 +0,0 @@
-using solidware.financials.infrastructure.eventing;
-using solidware.financials.windows.ui.events;
-
-namespace solidware.financials.windows.ui.presenters
-{
- public class IfFamilyMemberIsSelected : UISpecification<AddNewIncomeViewModel>,
- EventSubscriber<SelectedFamilyMember>
- {
- public override bool is_satisfied_by(AddNewIncomeViewModel item)
- {
- return is_selected;
- }
-
- public void notify(SelectedFamilyMember message)
- {
- is_selected = message != null;
- }
-
- bool is_selected;
- }
-}
\ No newline at end of file
product/desktop.ui/Properties/AssemblyInfo.cs
@@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2011.3.18.1329")]
-[assembly: AssemblyFileVersion("2011.3.18.1329")]
+[assembly: AssemblyVersion("2011.3.18.1348")]
+[assembly: AssemblyFileVersion("2011.3.18.1348")]
product/desktop.ui/ApplicationState.cs
@@ -4,5 +4,6 @@
{
Token PullOut<Token>();
void PushIn<Token>(Token token);
+ bool HasBeenPushedIn<Token>();
}
}
\ No newline at end of file
product/desktop.ui/InMemoryApplicationState.cs
@@ -17,5 +17,10 @@ namespace solidware.financials.windows.ui
{
database[typeof (Token)] = token;
}
+
+ public bool HasBeenPushedIn<Token>()
+ {
+ return database.ContainsKey(typeof(Token));
+ }
}
}
\ No newline at end of file
product/desktop.ui/solidware.financials.csproj
@@ -111,7 +111,7 @@
<Compile Include="ApplicationState.cs" />
<Compile Include="presenters\DisplayCanadianTaxInformationViewModel.cs" />
<Compile Include="model\PersonDetails.cs" />
- <Compile Include="presenters\IfFamilyMemberIsSelected.cs" />
+ <Compile Include="presenters\specifications\IfFamilyMemberIsSelected.cs" />
<Compile Include="presenters\SelectedFamilyMemberPresenter.cs" />
<Compile Include="presenters\TaxSummaryPresenter.cs" />
<Compile Include="presenters\StatusBarPresenter.cs" />
product/infrastructure/eventing/AnonymousSubscriber.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace solidware.financials.infrastructure.eventing
+{
+ public class AnonymousSubscriber<T> : EventSubscriber<T> where T : Event
+ {
+ Action<T> action;
+
+ public AnonymousSubscriber(Action<T> action)
+ {
+ this.action = action;
+ }
+
+ public void notify(T message)
+ {
+ action(message);
+ }
+ }
+}
\ No newline at end of file
product/infrastructure/infrastructure.csproj
@@ -46,6 +46,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="eventing\AnonymousSubscriber.cs" />
<Compile Include="eventing\Event.cs" />
<Compile Include="eventing\EventAggregator.cs" />
<Compile Include="eventing\EventSubscriber.cs" />
product/specs/unit/ui/presenters/specifications/IfFamilyMemberIsSelectedSpecs.cs
@@ -0,0 +1,46 @@
+using gorilla.utility;
+using Machine.Specifications;
+using Rhino.Mocks;
+using solidware.financials.windows.ui;
+using solidware.financials.windows.ui.events;
+using solidware.financials.windows.ui.presenters;
+using solidware.financials.windows.ui.presenters.specifications;
+
+namespace specs.unit.ui.presenters.specifications
+{
+ public class IfFamilyMemberIsSelectedSpecs
+ {
+ public abstract class concern
+ {
+ Establish context = () =>
+ {
+ state = Create.dependency<ApplicationState>();
+ sut = new IfFamilyMemberIsSelected<Presenter>(state);
+ };
+
+ static protected Specification<AddNewIncomeViewModel> sut;
+ static protected ApplicationState state;
+ }
+
+ public class when_a_family_member_has_been_selected : concern
+ {
+ It should_return_true = () =>
+ {
+ sut.is_satisfied_by(null).ShouldBeTrue();
+ };
+
+ Establish context = () =>
+ {
+ state.Stub(x => x.HasBeenPushedIn<SelectedFamilyMember>()).Return(true);
+ };
+ }
+
+ public class when_a_family_member_has_not_been_selected : concern
+ {
+ It should_return_false = () =>
+ {
+ sut.is_satisfied_by(null).ShouldBeFalse();
+ };
+ }
+ }
+}
\ No newline at end of file
product/specs/unit/ui/presenters/AddNewIncomeViewModelSpecs.cs
@@ -6,6 +6,7 @@ using solidware.financials.messages;
using solidware.financials.windows.ui;
using solidware.financials.windows.ui.events;
using solidware.financials.windows.ui.presenters;
+using solidware.financials.windows.ui.presenters.specifications;
namespace specs.unit.ui.presenters
{
@@ -56,7 +57,7 @@ namespace specs.unit.ui.presenters
Establish context = () =>
{
add_command = Create.an<IObservableCommand>();
- command_builder.Stub(x => x.build<AddNewIncomeViewModel.AddIncomeCommand, IfFamilyMemberIsSelected>(sut)).Return(add_command);
+ command_builder.Stub(x => x.build<AddNewIncomeViewModel.AddIncomeCommand, IfFamilyMemberIsSelected<AddNewIncomeViewModel>>(sut)).Return(add_command);
};
Because of = () =>
product/specs/unit/ui/InMemoryApplicationStateSpecs.cs
@@ -5,30 +5,48 @@ namespace specs.unit.ui
{
public class InMemoryApplicationStateSpecs
{
- public class when_storing_something_in_memory
+ public abstract class concern
{
- It should_be_easy_to_pull_it_out_of_memory = () =>
+ Establish context = () =>
{
- result.ShouldEqual(token);
+ sut = new InMemoryApplicationState();
};
- Establish context = () =>
+ static protected ApplicationState sut;
+ }
+
+ public class when_storing_something_in_memory : concern
+ {
+ It should_be_easy_to_pull_it_out_of_memory = () =>
{
- token = new TestToken();
- sut = new InMemoryApplicationState();
+ result.ShouldEqual(token);
};
Because of = () =>
{
+ token = new TestToken();
sut.PushIn(token);
result = sut.PullOut<TestToken>();
};
- static ApplicationState sut;
static TestToken token;
static TestToken result;
}
+ public class when_checking_if_a_token_has_been_added : concern
+ {
+ It should_tell_you_when_it_has = () =>
+ {
+ sut.PushIn(new TestToken());
+ sut.HasBeenPushedIn<TestToken>().ShouldBeTrue();
+ };
+
+ It should_tell_you_when_it_has_NOT = () =>
+ {
+ sut.HasBeenPushedIn<string>().ShouldBeFalse();
+ };
+ }
+
class TestToken {}
}
}
\ No newline at end of file
product/specs/specs.csproj
@@ -57,6 +57,7 @@
<Compile Include="unit\ui\InMemoryApplicationStateSpecs.cs" />
<Compile Include="unit\ui\presenters\AddFamilyMemberPresenterSpecs.cs" />
<Compile Include="unit\ui\presenters\AddNewIncomeViewModelSpecs.cs" />
+ <Compile Include="unit\ui\presenters\specifications\IfFamilyMemberIsSelectedSpecs.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\desktop.ui\solidware.financials.csproj">