Commit 4d9b258
Changed files (9)
trunk
src
MyMoney
Domain
accounting
billing
Infrastructure
Container
Threading
transactions
Presentation
Databindings
Views
Navigation
trunk/src/MyMoney/Domain/accounting/billing/bill_specs.cs
@@ -1,4 +1,5 @@
using System;
+using jpboodhoo.bdd.contexts;
using MyMoney.Domain.Core;
using MyMoney.Testing.Extensions;
using MyMoney.Testing.MetaData;
@@ -6,83 +7,78 @@ using MyMoney.Testing.spechelpers.contexts;
namespace MyMoney.Domain.accounting.billing
{
- public class bill_specs
- {}
-
[Concern(typeof (bill))]
- public class when_checking_to_see_if_a_new_bill_has_been_paid_for : old_context_specification<IBill>
+ public class when_checking_to_see_if_a_new_bill_has_been_paid_for : concerns_for<IBill>
{
- [Observation]
- public void it_should_return_false()
- {
- result.should_be_equal_to(false);
- }
+ it should_return_false = () => result.should_be_equal_to(false);
- protected override IBill context()
+ public override IBill create_sut()
{
- var amount_owed = new money(100);
- var enmax = an<ICompany>();
-
return new bill(enmax, amount_owed, DateTime.Now);
}
- protected override void because()
- {
- result = sut.is_paid_for();
- }
+ context c = () =>
+ {
+ amount_owed = new money(100);
+ enmax = an<ICompany>();
+ };
- private bool result;
+ because b = () => { result = sut.is_paid_for(); };
+
+ static bool result;
+ static IMoney amount_owed;
+ static ICompany enmax;
}
[Concern(typeof (bill))]
- public class when_checking_if_a_paid_bill_has_been_paid_for : old_context_specification<IBill>
+ public class when_checking_if_a_paid_bill_has_been_paid_for : concerns_for<IBill>
{
- [Observation]
- public void it_should_return_true()
- {
- result.should_be_equal_to(true);
- }
+ it should_return_true = () => result.should_be_equal_to(true);
- protected override IBill context()
- {
- one_hundred_twenty_three_dollars_fourty_five_cents = new money(123, 45);
- var direct_energy = an<ICompany>();
- return new bill(direct_energy, one_hundred_twenty_three_dollars_fourty_five_cents, DateTime.Now);
- }
- protected override void because()
+ context c = () =>
+ {
+ one_hundred_twenty_three_dollars_fourty_five_cents = new money(123, 45);
+ direct_energy = an<ICompany>();
+ };
+
+ because b = () =>
+ {
+ sut.pay(one_hundred_twenty_three_dollars_fourty_five_cents);
+ result = sut.is_paid_for();
+ };
+
+ public override IBill create_sut()
{
- sut.pay(one_hundred_twenty_three_dollars_fourty_five_cents);
- result = sut.is_paid_for();
+ return new bill(direct_energy, one_hundred_twenty_three_dollars_fourty_five_cents, DateTime.Now);
}
- private IMoney one_hundred_twenty_three_dollars_fourty_five_cents;
- private bool result;
+ static IMoney one_hundred_twenty_three_dollars_fourty_five_cents;
+ static bool result;
+ static ICompany direct_energy;
}
[Concern(typeof (bill))]
- public class when_checking_if_two_bills_are_the_same_and_they_are : old_context_specification<IBill>
+ public class when_checking_if_two_bills_are_the_same_and_they_are : concerns_for<IBill>
{
- [Observation]
- public void it_should_return_true()
- {
- result.should_be_equal_to(true);
- }
+ it should_return_true = () => result.should_be_equal_to(true);
- protected override IBill context()
- {
- company = an<ICompany>();
- due_date = new DateTime(2008, 01, 01);
- return new bill(company, new money(0), due_date);
- }
- protected override void because()
+ context c = () =>
+ {
+ company = an<ICompany>();
+ due_date = new DateTime(2008, 01, 01);
+ };
+
+ because b = () => { result = sut.Equals(new bill(company, new money(0), due_date)); };
+
+ public override IBill create_sut()
{
- result = sut.Equals(new bill(company, new money(0), due_date));
+ return new bill(company, new money(0), due_date);
}
- private ICompany company;
- private DateTime due_date;
- private bool result;
+ static ICompany company;
+ static DateTime due_date;
+ static bool result;
}
}
\ No newline at end of file
trunk/src/MyMoney/Domain/Core/date_specs.cs
@@ -1,53 +1,37 @@
+using jpboodhoo.bdd.contexts;
using MyMoney.Testing.Extensions;
using MyMoney.Testing.MetaData;
using MyMoney.Testing.spechelpers.contexts;
namespace MyMoney.Domain.Core
{
- public class date_specs
- {}
-
[Concern(typeof (date))]
- public class when_two_dates_that_represent_the_same_day_are_asked_if_they_are_equal : old_context_specification<IDate>
+ public class when_two_dates_that_represent_the_same_day_are_asked_if_they_are_equal : concerns_for<IDate>
{
- [Observation]
- public void it_should_return_true()
- {
- result.should_be_equal_to(true);
- }
+ it should_return_true = () => result.should_be_equal_to(true);
- protected override IDate context()
+ public override IDate create_sut()
{
return new date(2008, 09, 25);
}
- protected override void because()
- {
- result = sut.Equals(new date(2008, 09, 25));
- }
+ because b = () => { result = sut.Equals(new date(2008, 09, 25)); };
- private bool result;
+ static bool result;
}
[Concern(typeof (date))]
- public class when_an_older_date_is_compared_to_a_younger_date : old_context_specification<IDate>
+ public class when_an_older_date_is_compared_to_a_younger_date : concerns_for<IDate>
{
- [Observation]
- public void it_should_return_a_positive_number()
- {
- result.should_be_greater_than(0);
- }
+ it should_return_a_positive_number = () => result.should_be_greater_than(0);
- protected override IDate context()
+ public override IDate create_sut()
{
return new date(2008, 09, 25);
}
- protected override void because()
- {
- result = sut.CompareTo(new date(2007, 01, 01));
- }
+ because b = () => { result = sut.CompareTo(new date(2007, 01, 01)); };
- private int result;
+ static int result;
}
}
\ No newline at end of file
trunk/src/MyMoney/Domain/Core/money_specs.cs
@@ -1,71 +1,51 @@
+using jpboodhoo.bdd.contexts;
using MyMoney.Testing.Extensions;
using MyMoney.Testing.MetaData;
using MyMoney.Testing.spechelpers.contexts;
namespace MyMoney.Domain.Core
{
- public class money_specs
- {}
-
[Concern(typeof (money))]
- public class when_adding_two_monies_together : old_context_specification<IMoney>
+ public class when_adding_two_monies_together : concerns_for<IMoney>
{
- [Observation]
- public void it_should_return_the_correct_money()
- {
- result.should_be_equal_to(new money(2, 98));
- }
+ it should_return_the_correct_money = () => result.should_be_equal_to(new money(2, 98));
- protected override IMoney context()
- {
- return new money(0, 99);
- }
- protected override void because()
+ because b = () => { result = sut.add(new money(1, 99)); };
+
+ public override IMoney create_sut()
{
- result = sut.add(new money(1, 99));
+ return new money(0, 99);
}
- private IMoney result;
+ static IMoney result;
}
[Concern(typeof (money))]
- public class when_two_monies_of_the_same_value_are_compared_to_one_another : old_context_specification<IMoney>
+ public class when_two_monies_of_the_same_value_are_compared_to_one_another : concerns_for<IMoney>
{
- [Observation]
- public void they_should_be_equal()
- {
- result.should_be_equal_to(true);
- }
+ it they_should_be_equal = () => result.should_be_equal_to(true);
- protected override IMoney context()
- {
- return new money(1, 99);
- }
- protected override void because()
+ because b = () => { result = sut.Equals(new money(1, 99)); };
+
+ public override IMoney create_sut()
{
- result = sut.Equals(new money(1, 99));
+ return new money(1, 99);
}
- private bool result;
+ static bool result;
}
[Concern(typeof (money))]
- public class when_creating_a_money_with_pennies_greater_than_a_dollar : old_context_specification<IMoney>
+ public class when_creating_a_money_with_pennies_greater_than_a_dollar : concerns_for<IMoney>
{
- [Observation]
- public void it_should_create_a_money_representing_the_correct_amount_of_dollars_and_pennies()
- {
- sut.should_be_equal_to(new money(3, 00));
- }
+ it should_create_a_money_representing_the_correct_amount_of_dollars_and_pennies =
+ () => sut.should_be_equal_to(new money(3, 00));
- protected override IMoney context()
+ public override IMoney create_sut()
{
return new money(1, 200);
}
-
- protected override void because()
- {}
}
}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/Container/Windsor/windsor_dependency_registry_specs.cs
@@ -1,69 +1,57 @@
using Castle.Core;
using Castle.Windsor;
+using jpboodhoo.bdd.contexts;
using MyMoney.Testing.Extensions;
using MyMoney.Testing.MetaData;
using MyMoney.Testing.spechelpers.contexts;
namespace MyMoney.Infrastructure.Container.Windsor
{
- public class windsor_dependency_registry_specs
- {}
-
[Concern(typeof (windsor_dependency_registry))]
- public class when_registering_a_singleton_component_with_the_windsor_container : old_context_specification<IDependencyRegistry>
+ public class when_registering_a_singleton_component_with_the_windsor_container : concerns_for<IDependencyRegistry>
{
- [Observation]
- public void should_return_the_same_instance_each_time_its_resolved()
- {
- result.should_be_the_same_instance_as(sut.find_an_implementation_of<IBird>());
- }
+ it should_return_the_same_instance_each_time_its_resolved =
+ () => result.should_be_the_same_instance_as(sut.find_an_implementation_of<IBird>());
- [Observation]
- public void should_not_return_null()
- {
- result.should_not_be_null();
- }
+ it should_not_return_null = () => result.should_not_be_null();
- protected override IDependencyRegistry context()
+ public override IDependencyRegistry create_sut()
{
return new windsor_dependency_registry();
}
- protected override void because()
- {
- result = sut.find_an_implementation_of<IBird>();
- }
+ because b = () => { result = sut.find_an_implementation_of<IBird>(); };
- private IBird result;
+ static IBird result;
}
[Concern(typeof (windsor_dependency_registry))]
- public class when_creating_the_windsor_resolver_ : old_context_specification<IDependencyRegistry>
+ public class when_creating_the_windsor_resolver_ : concerns_for<IDependencyRegistry>
{
- [Observation]
- public void should_leverage_the_factory_to_create_the_underlying_container()
- {
- factory.was_told_to(f => f.create());
- }
+ it should_leverage_the_factory_to_create_the_underlying_container = () => factory.was_told_to(f => f.create());
- protected override IDependencyRegistry context()
+ public override IDependencyRegistry create_sut()
{
- var container = an<IWindsorContainer>();
- factory = an<IWindsorContainerFactory>();
- factory.is_told_to(f => f.create()).Return(container);
return new windsor_dependency_registry(factory);
}
- protected override void because()
- {}
+ context c = () =>
+ {
+ var container = an<IWindsorContainer>();
+ factory = an<IWindsorContainerFactory>();
+ factory.is_told_to(f => f.create()).it_will_return(container);
+ };
- private IWindsorContainerFactory factory;
+
+ static IWindsorContainerFactory factory;
}
[Singleton]
public class BlueBird : IBird
- {}
+ {
+ }
public interface IBird
- {}
+ {
+ }
}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/Threading/interval_timer_specs.cs
@@ -82,94 +82,61 @@ namespace MyMoney.Infrastructure.Threading
}
}
- [Concern(typeof (interval_timer))]
- public class when_a_timer_elapses : old_context_specification<ITimer>
+ public class when_a_timer_elapses : behaves_like_an_interval_timer
{
- [Observation]
- public void should_notify_the_timer_client()
- {
- client.was_told_to(c => c.notify());
- }
-
- ITimerFactory factory;
- ITimerClient client;
- Timer timer;
-
- protected override ITimer context()
- {
- factory = an<ITimerFactory>();
- client = an<ITimerClient>();
- timer = an<Timer>();
+ it should_notify_the_timer_client = () => client.was_told_to(c => c.notify());
- factory.is_told_to(f => f.create_for(Arg<TimeSpan>.Is.Anything)).Return(timer);
+ static ITimerClient client;
+ static Timer timer;
- return new interval_timer(factory);
- }
+ context c = () =>
+ {
+ client = an<ITimerClient>();
+ timer = dependency<Timer>();
+ factory.is_told_to(f => f.create_for(Arg<TimeSpan>.Is.Anything)).it_will_return(timer);
+ };
- protected override void because()
- {
- sut.start_notifying(client, new TimeSpan(0, 10, 0));
- timer.Raise(t => t.Elapsed += null, null, null);
- }
+ because b = () =>
+ {
+ sut.start_notifying(client, new TimeSpan(0, 10, 0));
+ timer.Raise(t => t.Elapsed += null, null, null);
+ };
}
- [Concern(typeof (interval_timer))]
- public class when_stopping_notifications_for_an_existing_timer_client : old_context_specification<ITimer>
+ public class when_stopping_notifications_for_an_existing_timer_client : behaves_like_an_interval_timer
{
- ITimerClient client;
- Timer timer;
+ static ITimerClient client;
+ static Timer timer;
- [Observation]
- public void should_stop_the_timer_that_was_started_for_the_client()
- {
- timer.was_told_to(t => t.Stop());
- }
+ it should_stop_the_timer_that_was_started_for_the_client = () => timer.was_told_to(t => t.Stop());
- [Observation]
- public void should_dispose_the_timer_that_was_started_for_the_client()
- {
- timer.was_told_to(t => t.Dispose());
- }
+ it should_dispose_the_timer_that_was_started_for_the_client = () => timer.was_told_to(t => t.Dispose());
- protected override ITimer context()
- {
- client = an<ITimerClient>();
- var factory = an<ITimerFactory>();
- timer = an<Timer>();
+ context c = () =>
+ {
+ client = an<ITimerClient>();
+ timer = dependency<Timer>();
- factory
- .is_told_to(t => t.create_for(Arg<TimeSpan>.Is.Anything))
- .Return(timer);
- return new interval_timer(factory);
- }
+ when_the(factory).is_told_to(t => t.create_for(Arg<TimeSpan>.Is.Anything)).it_will_return(
+ timer);
+ };
- protected override void because()
- {
- sut.start_notifying(client, new TimeSpan(0, 0, 1));
- sut.stop_notifying(client);
- }
+ because b = () =>
+ {
+ sut.start_notifying(client, new TimeSpan(0, 0, 1));
+ sut.stop_notifying(client);
+ };
}
- [Concern(typeof (interval_timer))]
public class when_attempting_to_stop_notification_for_a_client_that_doesnt_have_a_timer_started_for_it :
- old_context_specification<ITimer>
+ behaves_like_an_interval_timer
{
- [Observation]
- public void should_not_blow_up()
- {
- }
+ it should_not_blow_up = () => { };
- ITimerClient client;
+ context c = () => { client = an<ITimerClient>(); };
- protected override ITimer context()
- {
- client = an<ITimerClient>();
- return new interval_timer(null);
- }
+ because b = () => sut.stop_notifying(client);
- protected override void because()
- {
- sut.stop_notifying(client);
- }
+ static ITimerClient client;
}
}
\ No newline at end of file
trunk/src/MyMoney/Infrastructure/transactions/unit_of_work_specs.cs
@@ -1,3 +1,4 @@
+using jpboodhoo.bdd.contexts;
using MyMoney.Domain.Core;
using MyMoney.Testing.Extensions;
using MyMoney.Testing.MetaData;
@@ -5,38 +6,37 @@ using MyMoney.Testing.spechelpers.contexts;
namespace MyMoney.Infrastructure.transactions
{
- public class unit_of_work_specs
- {}
-
[Concern(typeof (unit_of_work<IEntity>))]
- public class when_committing_a_unit_of_work : old_context_specification<IUnitOfWork<IEntity>>
+ public class when_committing_a_unit_of_work : concerns_for<IUnitOfWork<IEntity>>
{
- [Observation]
- public void it_should_save_each_registered_item()
- {
- repository.was_told_to(x => x.save(first_item));
- repository.was_told_to(x => x.save(second_item));
- }
+ it should_save_each_registered_item = () =>
+ {
+ repository.was_told_to(x => x.save(first_item));
+ repository.was_told_to(x => x.save(second_item));
+ };
- protected override IUnitOfWork<IEntity> context()
+ public override IUnitOfWork<IEntity> create_sut()
{
- repository = an<IRepository>();
-
- first_item = an<IEntity>();
- second_item = an<IEntity>();
-
return new unit_of_work<IEntity>(repository);
}
- protected override void because()
- {
- sut.register(first_item);
- sut.register(second_item);
- sut.commit();
- }
+ context c = () =>
+ {
+ repository = an<IRepository>();
+
+ first_item = an<IEntity>();
+ second_item = an<IEntity>();
+ };
+
+ because b = () =>
+ {
+ sut.register(first_item);
+ sut.register(second_item);
+ sut.commit();
+ };
- private IRepository repository;
- private IEntity first_item;
- private IEntity second_item;
+ static IRepository repository;
+ static IEntity first_item;
+ static IEntity second_item;
}
}
\ No newline at end of file
trunk/src/MyMoney/Presentation/Databindings/binding_selector_specs.cs
@@ -1,56 +1,51 @@
using System;
using System.Linq.Expressions;
+using jpboodhoo.bdd.contexts;
using MyMoney.Testing.Extensions;
using MyMoney.Testing.MetaData;
using MyMoney.Testing.spechelpers.contexts;
namespace MyMoney.Presentation.Databindings
{
- public class binding_selector_specs
- {}
-
[Concern(typeof (binding_selector<IAnInterface>))]
- public class when_selecting_a_property_as_the_target_of_a_binding : old_context_specification<IBindingSelector<IAnInterface>>
+ public class when_selecting_a_property_as_the_target_of_a_binding : concerns_for<IBindingSelector<IAnInterface>>
{
- [Observation]
- public void should_return_a_binder_bound_to_the_correct_property()
- {
- result.property.Name.should_be_equal_to("FirstName");
- }
-
- [Observation]
- public void should_inspect_the_expression_for_the_property_information()
- {
- inspector.was_told_to(i => i.inspect(expression_to_parse));
- }
-
- protected override IBindingSelector<IAnInterface> context()
+ it should_return_a_binder_bound_to_the_correct_property =
+ () => result.property.Name.should_be_equal_to("FirstName");
+
+ it should_inspect_the_expression_for_the_property_information =
+ () => inspector.was_told_to(i => i.inspect(expression_to_parse));
+
+ context c = () =>
+ {
+ thing_to_bind_to = an<IAnInterface>();
+ factory = an<IPropertyInspectorFactory>();
+ inspector = an<IPropertyInspector<IAnInterface, string>>();
+
+ factory
+ .is_told_to(f => f.create<IAnInterface, string>())
+ .it_will_return(inspector);
+
+ inspector.is_told_to(i => i.inspect(null))
+ .IgnoreArguments()
+ .it_will_return(typeof (IAnInterface).GetProperty("FirstName"));
+ };
+
+ because b = () =>
+ {
+ expression_to_parse = (s => s.FirstName);
+ result = sut.bind_to_property(expression_to_parse);
+ };
+
+ public override IBindingSelector<IAnInterface> create_sut()
{
- thing_to_bind_to = an<IAnInterface>();
- factory = an<IPropertyInspectorFactory>();
- inspector = an<IPropertyInspector<IAnInterface, string>>();
-
- factory
- .is_told_to(f => f.create<IAnInterface, string>())
- .Return(inspector);
-
- inspector.is_told_to(i => i.inspect(null))
- .IgnoreArguments()
- .Return(typeof (IAnInterface).GetProperty("FirstName"));
-
return new binding_selector<IAnInterface>(thing_to_bind_to, factory);
}
- protected override void because()
- {
- expression_to_parse = (s => s.FirstName);
- result = sut.bind_to_property(expression_to_parse);
- }
-
- private IAnInterface thing_to_bind_to;
- private IPropertyBinder<IAnInterface, string> result;
- private IPropertyInspectorFactory factory;
- private IPropertyInspector<IAnInterface, string> inspector;
- private Expression<Func<IAnInterface, string>> expression_to_parse;
+ static IAnInterface thing_to_bind_to;
+ static IPropertyBinder<IAnInterface, string> result;
+ static IPropertyInspectorFactory factory;
+ static IPropertyInspector<IAnInterface, string> inspector;
+ static Expression<Func<IAnInterface, string>> expression_to_parse;
}
}
\ No newline at end of file