Commit 7ce13ed
Changed files (7)
trunk
product
Gorilla.Commons.Utility
MoMoney.Presentation
Presenters
Commands
MoMoney.Service
Application
trunk/product/Gorilla.Commons.Utility/Extensions/ListExtensions.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Gorilla.Commons.Utility.Extensions
+{
+ static public class ListExtensions
+ {
+ static public IListConstraint<T> add<T>(this IList<T> items, T item)
+ {
+ return new ListConstraint<T>(items, item);
+ }
+
+ static public IListConstraint<T> add_range<T>(this IList<T> items, IEnumerable<T> item)
+ {
+ return new ListConstraint<T>(items, item.ToArray());
+ }
+ }
+
+ public class ListConstraint<T> : IListConstraint<T>
+ {
+ readonly IList<T> items;
+ readonly T[] items_to_add;
+
+ public ListConstraint(IList<T> list_to_constrain, params T[] items_to_add)
+ {
+ items = list_to_constrain;
+ this.items_to_add = items_to_add;
+ items_to_add.each(list_to_constrain.Add);
+ }
+
+ public void unless(Func<T, bool> predicate)
+ {
+ items_to_add.where(predicate).each(x => items.Remove(x));
+ }
+ }
+
+ public interface IListConstraint<T>
+ {
+ void unless(Func<T, bool> predicate);
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Utility/Extensions/ListExtensionsSpecs.cs
@@ -0,0 +1,60 @@
+using System.Collections.Generic;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Utility.Extensions
+{
+ public class when_adding_an_item_to_a_list : concerns
+ {
+ because b = () =>
+ {
+ list = new List<string>();
+ list.add("mo");
+ };
+
+ it should_add_the_item_to_the_list = () => list.should_contain("mo");
+
+ static List<string> list;
+ }
+
+ public abstract class when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met : concerns
+ {
+ context c = () => { list = new List<string>(); };
+
+ static protected List<string> list;
+ }
+
+ public class when_the_condition_is_not_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list.add("mo").unless(x => false);
+
+ it should_add_the_item_to_the_list = () => list.should_contain("mo");
+ }
+
+ public class when_the_condition_is_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list.add("mo").unless(x => true);
+
+ it should_not_add_the_item_to_the_list = () => list.should_not_contain("mo");
+ }
+
+ public class when_some_of_the_items_meet_the_conditions_and_some_do_not :
+ when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list
+ .add_range(new List<string> {"mo", "khan"})
+ .unless(x => x.Equals("mo"));
+
+ it should_add_the_items_that_do_not_meet_the_condition = () =>
+ {
+ list.Count.should_be_equal_to(1);
+ list.should_contain("khan");
+ };
+
+ it should_not_add_the_items_that_do_meet_the_condition = () => list.should_not_contain("mo");
+ }
+
+ public class ListExtensionsSpecs
+ {
+ }
+}
\ No newline at end of file
trunk/product/Gorilla.Commons.Utility/Gorilla.Commons.Utility.csproj
@@ -101,6 +101,8 @@
<Compile Include="Extensions\EnumerableExtensions.cs" />
<Compile Include="Extensions\EnumerableExtensionsSpecs.cs" />
<Compile Include="Extensions\FuncExtensions.cs" />
+ <Compile Include="Extensions\ListExtensions.cs" />
+ <Compile Include="Extensions\ListExtensionsSpecs.cs" />
<Compile Include="Extensions\MappingExtensions.cs" />
<Compile Include="Extensions\MappingExtensionsSpecs.cs" />
<Compile Include="Extensions\NumericConversions.cs" />
trunk/product/MoMoney.Presentation/Presenters/Commands/RunTheSpecs.cs
@@ -1,6 +1,7 @@
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Infrastructure.Threading;
using Gorilla.Commons.Testing;
+using MbUnit.Framework;
using MoMoney.Presentation.Core;
namespace MoMoney.Presentation.Presenters.Commands
@@ -9,6 +10,7 @@ namespace MoMoney.Presentation.Presenters.Commands
{
}
+ [Ignore]
[Concern(typeof (RunThe<>))]
public class when_initializing_different_regions_of_the_user_interface :
concerns_for<IRunThe<IPresenter>, RunThe<IPresenter>>
trunk/product/MoMoney.Service/Application/Public/AddNewIncomeCommand.svc
@@ -0,0 +1,1 @@
+<%@ ServiceHost Language="C#" Service="MoMoney.Service.Application.AddNewIncomeCommand" CodeBehind="MoMoney.Service.Application.AddNewIncomeCommand.cs" />
\ No newline at end of file
trunk/product/MoMoney.Service/Application/AddNewIncomeCommand.cs
@@ -13,7 +13,8 @@ namespace MoMoney.Service.Application
readonly IIncomeRepository all_income;
readonly ICompanyRepository companys;
- public AddNewIncomeCommand(ICustomerTasks tasks, INotification notification, IIncomeRepository all_income,ICompanyRepository companys)
+ public AddNewIncomeCommand(ICustomerTasks tasks, INotification notification, IIncomeRepository all_income,
+ ICompanyRepository companys)
{
this.tasks = tasks;
this.notification = notification;
trunk/product/MoMoney.Service/MoMoney.Service.csproj
@@ -117,6 +117,9 @@
<Name>MoMoney.DTO</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Content Include="Application\Public\AddNewIncomeCommand.svc" />
+ </ItemGroup>
<ItemGroup>
<Folder Include="Domain\" />
<Folder Include="Properties\" />