Commit a1b7ef1
Changed files (49)
trunk
product
MoMoney.DataAccess
MoMoney.Domain
Accounting
Repositories
MoMoney.DTO
MoMoney.Infrastructure
Eventing
Interceptors
Transactions
Transactions2
MoMoney.Presentation
Model
Presenters
MoMoney.Service
Application
MyMoney
boot
trunk/product/MoMoney.DataAccess/Db40/ObjectDatabaseGateway.cs
@@ -5,31 +5,31 @@ using MoMoney.Infrastructure.transactions2;
namespace MoMoney.DataAccess.db40
{
- public class ObjectDatabaseGateway : IDatabaseGateway
- {
- readonly ISessionContext context;
- readonly ISessionProvider session_provider;
+ //public class ObjectDatabaseGateway : IDatabaseGateway
+ //{
+ // readonly ISessionContext context;
+ // readonly ISessionProvider session_provider;
- public ObjectDatabaseGateway(ISessionContext context, ISessionProvider session_provider)
- {
- this.context = context;
- this.session_provider = session_provider;
- }
+ // public ObjectDatabaseGateway(ISessionContext context, ISessionProvider session_provider)
+ // {
+ // this.context = context;
+ // this.session_provider = session_provider;
+ // }
- public IEnumerable<T> all<T>() where T : IEntity
- {
- return open_session_with_database().all<T>();
- }
+ // public IEnumerable<T> all<T>() where T : IEntity
+ // {
+ // return open_session_with_database().all<T>();
+ // }
- public void save<T>(T item) where T : IEntity
- {
- open_session_with_database().save(item);
- }
+ // public void save<T>(T item) where T : IEntity
+ // {
+ // open_session_with_database().save(item);
+ // }
- Infrastructure.transactions2.ISession open_session_with_database()
- {
- return session_provider.get_the_current_session();
- //return context.current_session();
- }
- }
+ // Infrastructure.transactions2.ISession open_session_with_database()
+ // {
+ // return session_provider.get_the_current_session();
+ // //return context.current_session();
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/Db40/ObjectDatabaseGatewaySpecs.cs
@@ -7,45 +7,45 @@ using MoMoney.Infrastructure.transactions2;
namespace MoMoney.DataAccess.db40
{
- [Concern(typeof (ObjectDatabaseGateway))]
- public abstract class behaves_like_a_object_repository : concerns_for<IDatabaseGateway, ObjectDatabaseGateway>
- {
- context c = () =>
- {
- context = the_dependency<ISessionContext>();
- provider = the_dependency<ISessionProvider>();
- };
-
- protected static ISessionContext context;
- protected static ISessionProvider provider;
- }
-
- public class when_loading_all_the_items_from_the_database : behaves_like_a_object_repository
- {
- it should_return_all_the_items_from_the_database = () =>
- {
- result.should_contain(first_item);
- result.should_contain(second_item);
- };
-
- context c = () =>
- {
- first_item = an<IEntity>();
- second_item = an<IEntity>();
- var session = an<Infrastructure.transactions2.ISession>();
-
- //context.is_told_to(x => x.current_session()).it_will_return(session);
- //session.is_told_to(x => x.query<IEntity>()).it_will_return(new List<IEntity> {first_item, second_item});
-
-
- provider.is_told_to(x => x.get_the_current_session()).it_will_return(session);
- when_the(session).is_told_to(x => x.all<IEntity>()).it_will_return(first_item, second_item);
- };
-
- because b = () => { result = sut.all<IEntity>(); };
-
- static IEnumerable<IEntity> result;
- static IEntity first_item;
- static IEntity second_item;
- }
+ //[Concern(typeof (ObjectDatabaseGateway))]
+ //public abstract class behaves_like_a_object_repository : concerns_for<IDatabaseGateway, ObjectDatabaseGateway>
+ //{
+ // context c = () =>
+ // {
+ // context = the_dependency<ISessionContext>();
+ // provider = the_dependency<ISessionProvider>();
+ // };
+
+ // protected static ISessionContext context;
+ // protected static ISessionProvider provider;
+ //}
+
+ //public class when_loading_all_the_items_from_the_database : behaves_like_a_object_repository
+ //{
+ // it should_return_all_the_items_from_the_database = () =>
+ // {
+ // result.should_contain(first_item);
+ // result.should_contain(second_item);
+ // };
+
+ // context c = () =>
+ // {
+ // first_item = an<IEntity>();
+ // second_item = an<IEntity>();
+ // var session = an<Infrastructure.transactions2.ISession>();
+
+ // //context.is_told_to(x => x.current_session()).it_will_return(session);
+ // //session.is_told_to(x => x.query<IEntity>()).it_will_return(new List<IEntity> {first_item, second_item});
+
+
+ // provider.is_told_to(x => x.get_the_current_session()).it_will_return(session);
+ // when_the(session).is_told_to(x => x.all<IEntity>()).it_will_return(first_item, second_item);
+ // };
+
+ // because b = () => { result = sut.all<IEntity>(); };
+
+ // static IEnumerable<IEntity> result;
+ // static IEntity first_item;
+ // static IEntity second_item;
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/Repositories/AccountHolderRepository.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using MoMoney.Domain.accounting;
+using MoMoney.Domain.repositories;
+using MoMoney.Infrastructure.transactions2;
+
+namespace MoMoney.DataAccess.repositories
+{
+ public class AccountHolderRepository : IAccountHolderRepository
+ {
+ readonly ISession session;
+
+ public AccountHolderRepository(ISession session)
+ {
+ this.session = session;
+ }
+
+ public IEnumerable<IAccountHolder> all()
+ {
+ return session.all<IAccountHolder>();
+ }
+
+ public void save(IAccountHolder account_holder)
+ {
+ session.save(account_holder);
+ }
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/Repositories/BillRepository.cs
@@ -1,22 +1,22 @@
using System.Collections.Generic;
-using MoMoney.DataAccess.core;
using MoMoney.Domain.accounting.billing;
using MoMoney.Domain.repositories;
+using MoMoney.Infrastructure.transactions2;
namespace MoMoney.DataAccess.repositories
{
public class BillRepository : IBillRepository
{
- readonly IDatabaseGateway gateway;
+ readonly ISession session;
- public BillRepository(IDatabaseGateway gateway)
+ public BillRepository(ISession session)
{
- this.gateway = gateway;
+ this.session = session;
}
public IEnumerable<IBill> all()
{
- return gateway.all<IBill>();
+ return session.all<IBill>();
}
}
}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/Repositories/BillRepositorySpecs.cs
@@ -8,19 +8,19 @@ using MoMoney.Testing.spechelpers.contexts;
namespace MoMoney.DataAccess.repositories
{
- public class when_loading_all_the_bills_from_the_repository : behaves_like_a_repository
- {
- it should_return_all_the_bills_in_the_database = () => results.should_contain(first_bill);
+ //public class when_loading_all_the_bills_from_the_repository : behaves_like_a_repository
+ //{
+ // it should_return_all_the_bills_in_the_database = () => results.should_contain(first_bill);
- context c = () => { first_bill = new Bill(new Company(), new Money(1, 00), DateTime.Now); };
+ // context c = () => { first_bill = new Bill(new Company(), new Money(1, 00), DateTime.Now); };
- because b = () =>
- {
- sut.save(first_bill);
- results = sut.all<IBill>();
- };
+ // because b = () =>
+ // {
+ // sut.save(first_bill);
+ // results = sut.all<IBill>();
+ // };
- static IEnumerable<IBill> results;
- static IBill first_bill;
- }
+ // static IEnumerable<IBill> results;
+ // static IBill first_bill;
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/Repositories/CompanyRepository.cs
@@ -2,41 +2,41 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Gorilla.Commons.Utility.Extensions;
-using MoMoney.DataAccess.core;
using MoMoney.Domain.accounting.billing;
using MoMoney.Domain.repositories;
+using MoMoney.Infrastructure.transactions2;
namespace MoMoney.DataAccess.repositories
{
public class CompanyRepository : ICompanyRepository
{
- readonly IDatabaseGateway gateway;
+ readonly ISession session;
- public CompanyRepository(IDatabaseGateway gateway)
+ public CompanyRepository(ISession session)
{
- this.gateway = gateway;
+ this.session = session;
}
public IEnumerable<ICompany> all()
{
- return gateway.all<ICompany>();
+ return session.all<ICompany>();
}
public ICompany find_company_named(string name)
{
- return gateway
+ return session
.all<ICompany>()
.SingleOrDefault(x => x.name.is_equal_to_ignoring_case(name));
}
public ICompany find_company_by(Guid id)
{
- return gateway.all<ICompany>().SingleOrDefault(x => x.id.Equals(id));
+ return session.all<ICompany>().SingleOrDefault(x => x.id.Equals(id));
}
public void save(ICompany company)
{
- gateway.save(company);
+ session.save(company);
}
}
}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/Repositories/IncomeRepository.cs
@@ -1,22 +1,22 @@
using System.Collections.Generic;
-using MoMoney.DataAccess.core;
using MoMoney.Domain.accounting.financial_growth;
using MoMoney.Domain.repositories;
+using MoMoney.Infrastructure.transactions2;
namespace MoMoney.DataAccess.repositories
{
public class IncomeRepository : IIncomeRepository
{
- readonly IDatabaseGateway gateway;
+ readonly ISession session;
- public IncomeRepository(IDatabaseGateway gateway)
+ public IncomeRepository(ISession session)
{
- this.gateway = gateway;
+ this.session = session;
}
public IEnumerable<IIncome> all()
{
- return gateway.all<IIncome>();
+ return session.all<IIncome>();
}
}
}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/Testing/behaves_like_a_repository.cs
@@ -8,24 +8,24 @@ using MoMoney.Testing.MetaData;
namespace MoMoney.Testing.spechelpers.contexts
{
- [RunInRealContainer]
- [Concern(typeof (IDatabaseGateway))]
- [Ignore]
- public abstract class behaves_like_a_repository : concerns_for<IDatabaseGateway>
- {
- public override IDatabaseGateway create_sut()
- {
- return resolve.dependency_for<IDatabaseGateway>();
- }
+ //[RunInRealContainer]
+ //[Concern(typeof (IDatabaseGateway))]
+ //[Ignore]
+ //public abstract class behaves_like_a_repository : concerns_for<IDatabaseGateway>
+ //{
+ // public override IDatabaseGateway create_sut()
+ // {
+ // return resolve.dependency_for<IDatabaseGateway>();
+ // }
- context c = () =>
- {
- session = resolve.dependency_for<ISessionFactory>().create();
- resolve.dependency_for<IContext>().add(resolve.dependency_for<IKey<ISession>>(), session);
- };
+ // context c = () =>
+ // {
+ // session = resolve.dependency_for<ISessionFactory>().create();
+ // resolve.dependency_for<IContext>().add(resolve.dependency_for<IKey<ISession>>(), session);
+ // };
- after_each_observation after = () => session.Dispose();
+ // after_each_observation after = () => session.Dispose();
- static ISession session;
- }
+ // static ISession session;
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.DataAccess/MoMoney.DataAccess.csproj
@@ -73,12 +73,11 @@
<Compile Include="Db40\AttachedSession.cs" />
<Compile Include="Db40\ConnectionFactory.cs" />
<Compile Include="Db40\DetachedSession.cs" />
- <Compile Include="Db40\ObjectDatabaseGateway.cs" />
- <Compile Include="Db40\ObjectDatabaseGatewaySpecs.cs" />
<Compile Include="Db40\SessionContext.cs" />
<Compile Include="Db40\SessionContextSpecs.cs" />
<Compile Include="Db40\Spiking\db40_spike_specs.cs" />
<Compile Include="IFile.cs" />
+ <Compile Include="Repositories\AccountHolderRepository.cs" />
<Compile Include="Repositories\BillRepository.cs" />
<Compile Include="Repositories\BillRepositorySpecs.cs" />
<Compile Include="Repositories\CompanyRepository.cs" />
trunk/product/MoMoney.Domain/Accounting/Billing/Company.cs
@@ -24,12 +24,12 @@ namespace MoMoney.Domain.accounting.billing
public void issue_bill_to(IAccountHolder customer, DateTime that_is_due_on, IMoney for_amount)
{
- customer.recieve(new Bill(this, for_amount, that_is_due_on));
+ customer.receive(new Bill(this, for_amount, that_is_due_on));
}
public void pay(IAccountHolder person, IMoney amount, IDate date_of_payment)
{
- person.recieve(new Income(date_of_payment, amount, this));
+ person.receive(new Income(date_of_payment, amount, this));
}
public override string ToString()
trunk/product/MoMoney.Domain/Accounting/AccountHolder.cs
@@ -9,8 +9,8 @@ namespace MoMoney.Domain.accounting
{
public interface IAccountHolder : IEntity
{
- void recieve(IBill bill);
- void recieve(IIncome income);
+ void receive(IBill bill);
+ void receive(IIncome income);
IEnumerable<IBill> collect_all_the_unpaid_bills();
IMoney calculate_income_for(IYear year);
}
@@ -27,7 +27,7 @@ namespace MoMoney.Domain.accounting
private IList<IBill> all_bills { get; set; }
private IList<IIncome> income_collected { get; set; }
- public void recieve(IBill bill)
+ public void receive(IBill bill)
{
all_bills.Add(bill);
}
@@ -42,7 +42,7 @@ namespace MoMoney.Domain.accounting
return income_collected.in_the(year);
}
- public void recieve(IIncome income)
+ public void receive(IIncome income)
{
income_collected.Add(income);
}
trunk/product/MoMoney.Domain/Accounting/AccountHolderSpecs.cs
@@ -38,9 +38,9 @@ namespace MoMoney.Domain.accounting
because b = () =>
{
- sut.recieve(first_unpaid_bill);
- sut.recieve(paid_bill);
- sut.recieve(second_unpaid_bill);
+ sut.receive(first_unpaid_bill);
+ sut.receive(paid_bill);
+ sut.receive(second_unpaid_bill);
result = sut.collect_all_the_unpaid_bills();
};
@@ -76,9 +76,9 @@ namespace MoMoney.Domain.accounting
because b = () =>
{
- sut.recieve(income_for_january_2007);
- sut.recieve(income_for_february_2007);
- sut.recieve(income_for_february_2008);
+ sut.receive(income_for_january_2007);
+ sut.receive(income_for_february_2007);
+ sut.receive(income_for_february_2008);
result = sut.calculate_income_for(2007.as_a_year());
};
trunk/product/MoMoney.Domain/Repositories/IAccountHolderRepository.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using MoMoney.Domain.accounting;
+
+namespace MoMoney.Domain.repositories
+{
+ public interface IAccountHolderRepository
+ {
+ IEnumerable<IAccountHolder> all();
+ void save(IAccountHolder account_holder);
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.Domain/MoMoney.Domain.csproj
@@ -90,6 +90,7 @@
<Compile Include="Core\PercentSpecs.cs" />
<Compile Include="Core\range.cs" />
<Compile Include="Core\range_specs.cs" />
+ <Compile Include="Repositories\IAccountHolderRepository.cs" />
<Compile Include="Repositories\IBillRepository.cs" />
<Compile Include="Repositories\ICompanyRepository.cs" />
<Compile Include="Repositories\IIncomeRepository.cs" />
trunk/product/MoMoney.DTO/RegisterNewCompany.cs
@@ -1,4 +1,4 @@
-namespace MoMoney.Presentation.Presenters.billing.dto
+namespace MoMoney.DTO
{
public class RegisterNewCompany
{
trunk/product/MoMoney.Infrastructure/Eventing/EventAggregator.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using Gorilla.Commons.Utility.Extensions;
+using MoMoney.Infrastructure.Extensions;
namespace MoMoney.Infrastructure.eventing
{
@@ -40,11 +41,13 @@ namespace MoMoney.Infrastructure.eventing
public void publish<Event>(Event the_event_to_broadcast) where Event : IEvent
{
+ this.log().debug("publishing: {0}", the_event_to_broadcast);
process(() => subscribers.call_on_each<IEventSubscriber<Event>>(x => x.notify(the_event_to_broadcast)));
}
public void publish<T>(Expression<Action<T>> call) where T : class
{
+ this.log().debug("publishing: {0}", call);
process(() => subscribers.each(x => x.call_on(call.Compile())));
}
trunk/product/MoMoney.Infrastructure/Interceptors/UnitOfWorkInterceptor.cs
@@ -5,29 +5,29 @@ using MoMoney.Infrastructure.transactions;
namespace MoMoney.Infrastructure.interceptors
{
- public interface IUnitOfWorkInterceptor : IInterceptor
- {
- }
+ //public interface IUnitOfWorkInterceptor : IInterceptor
+ //{
+ //}
- public class UnitOfWorkInterceptor : IUnitOfWorkInterceptor
- {
- readonly IUnitOfWorkRegistry registry;
- readonly IEventAggregator broker;
+ //public class UnitOfWorkInterceptor : IUnitOfWorkInterceptor
+ //{
+ // readonly IUnitOfWorkRegistry registry;
+ // readonly IEventAggregator broker;
- public UnitOfWorkInterceptor(IUnitOfWorkRegistry registry, IEventAggregator broker)
- {
- this.registry = registry;
- this.broker = broker;
- }
+ // public UnitOfWorkInterceptor(IUnitOfWorkRegistry registry, IEventAggregator broker)
+ // {
+ // this.registry = registry;
+ // this.broker = broker;
+ // }
- public void Intercept(IInvocation invocation)
- {
- invocation.Proceed();
- if (registry.has_changes_to_commit())
- {
- registry.commit_all();
- //broker.publish<UnsavedChangesEvent>();
- }
- }
- }
+ // public void Intercept(IInvocation invocation)
+ // {
+ // invocation.Proceed();
+ // if (registry.has_changes_to_commit())
+ // {
+ // registry.commit_all();
+ // //broker.publish<UnsavedChangesEvent>();
+ // }
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/IDatabaseGateway.cs
@@ -3,9 +3,9 @@ using MoMoney.Domain.Core;
namespace MoMoney.DataAccess.core
{
- public interface IDatabaseGateway
- {
- IEnumerable<T> all<T>() where T : IEntity;
- void save<T>(T item) where T : IEntity;
- }
+ //public interface IDatabaseGateway
+ //{
+ // IEnumerable<T> all<T>() where T : IEntity;
+ // void save<T>(T item) where T : IEntity;
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/IUnitOfWorkRegistrationFactory.cs
@@ -1,6 +0,0 @@
-using MoMoney.Utility.Core;
-
-namespace MoMoney.Infrastructure.transactions
-{
-
-}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/NullUnitOfWork.cs
@@ -2,23 +2,23 @@ using MoMoney.Domain.Core;
namespace MoMoney.Infrastructure.transactions
{
- internal class NullUnitOfWork<T> : IUnitOfWork<T> where T : IEntity
- {
- public void register(T entity)
- {
- }
+ //internal class NullUnitOfWork<T> : IUnitOfWork<T> where T : IEntity
+ //{
+ // public void register(T entity)
+ // {
+ // }
- public void commit()
- {
- }
+ // public void commit()
+ // {
+ // }
- public bool is_dirty()
- {
- return false;
- }
+ // public bool is_dirty()
+ // {
+ // return false;
+ // }
- public void Dispose()
- {
- }
- }
+ // public void Dispose()
+ // {
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/unit_of_work.cs
@@ -7,48 +7,48 @@ using MoMoney.Domain.Core;
namespace MoMoney.Infrastructure.transactions
{
- public interface IUnitOfWork : IDisposable
- {
- void commit();
- bool is_dirty();
- }
-
- public interface IUnitOfWork<T> : IUnitOfWork where T : IEntity
- {
- void register(T entity);
- }
-
- public class unit_of_work<T> : IUnitOfWork<T> where T : IEntity
- {
- readonly IDatabaseGateway gateway;
- readonly IUnitOfWorkRegistrationFactory<T> factory;
- readonly IList<IUnitOfWorkRegistration<T>> registered_items;
-
- public unit_of_work(IDatabaseGateway repository, IUnitOfWorkRegistrationFactory<T> factory)
- {
- gateway = repository;
- this.factory = factory;
- registered_items = new List<IUnitOfWorkRegistration<T>>();
- }
-
- public void register(T entity)
- {
- registered_items.Add(factory.map_from(entity));
- }
-
- public void commit()
- {
- registered_items.each(x => { if (x.contains_changes()) gateway.save(x.current); });
- }
-
- public bool is_dirty()
- {
- return registered_items.Count(x => x.contains_changes()) > 0;
- }
-
- public void Dispose()
- {
- registered_items.Clear();
- }
- }
+ //public interface IUnitOfWork : IDisposable
+ //{
+ // void commit();
+ // bool is_dirty();
+ //}
+
+ //public interface IUnitOfWork<T> : IUnitOfWork where T : IEntity
+ //{
+ // void register(T entity);
+ //}
+
+ //public class unit_of_work<T> : IUnitOfWork<T> where T : IEntity
+ //{
+ // readonly IDatabaseGateway gateway;
+ // readonly IUnitOfWorkRegistrationFactory<T> factory;
+ // readonly IList<IUnitOfWorkRegistration<T>> registered_items;
+
+ // public unit_of_work(IDatabaseGateway repository, IUnitOfWorkRegistrationFactory<T> factory)
+ // {
+ // gateway = repository;
+ // this.factory = factory;
+ // registered_items = new List<IUnitOfWorkRegistration<T>>();
+ // }
+
+ // public void register(T entity)
+ // {
+ // registered_items.Add(factory.map_from(entity));
+ // }
+
+ // public void commit()
+ // {
+ // registered_items.each(x => { if (x.contains_changes()) gateway.save(x.current); });
+ // }
+
+ // public bool is_dirty()
+ // {
+ // return registered_items.Count(x => x.contains_changes()) > 0;
+ // }
+
+ // public void Dispose()
+ // {
+ // registered_items.Clear();
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/unit_of_work_specs.cs
@@ -5,104 +5,104 @@ using MoMoney.Domain.Core;
namespace MoMoney.Infrastructure.transactions
{
- [Concern(typeof (unit_of_work<IEntity>))]
- public abstract class behaves_like_a_unit_of_work : concerns_for<IUnitOfWork<IEntity>, unit_of_work<IEntity>>
- {
- public override IUnitOfWork<IEntity> create_sut()
- {
- return new unit_of_work<IEntity>(repository, factory);
- }
-
- context c = () =>
- {
- repository = the_dependency<IDatabaseGateway>();
- factory = the_dependency<IUnitOfWorkRegistrationFactory<IEntity>>();
- };
-
- protected static IDatabaseGateway repository;
- protected static IUnitOfWorkRegistrationFactory<IEntity> factory;
- }
-
- public class when_committing_a_unit_of_work : behaves_like_a_unit_of_work
- {
- it should_save_each_registered_item = () =>
- {
- repository.was_told_to(x => x.save(first_item));
- repository.was_told_to(x => x.save(second_item));
- };
-
- context c = () =>
- {
- first_item = an<IEntity>();
- second_item = an<IEntity>();
-
- var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
- var second_registration = an<IUnitOfWorkRegistration<IEntity>>();
-
- when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
- when_the(factory).is_told_to(x => x.map_from(second_item)).it_will_return(
- second_registration);
- when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
- when_the(second_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
- when_the(first_registration).is_told_to(x => x.current).it_will_return(first_item);
- when_the(second_registration).is_told_to(x => x.current).it_will_return(second_item);
- };
-
- because b = () =>
- {
- sut.register(first_item);
- sut.register(second_item);
- sut.commit();
- };
-
- static IEntity first_item;
- static IEntity second_item;
- }
-
- public class when_checking_if_there_are_changes_and_there_are : behaves_like_a_unit_of_work
- {
- it should_tell_the_truth = () => result.should_be_true();
-
- context c = () =>
- {
- first_item = an<IEntity>();
- var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
-
- when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
- when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
- when_the(first_registration).is_told_to(x => x.current).it_will_return(first_item);
- };
-
- because b = () =>
- {
- sut.register(first_item);
- result = sut.is_dirty();
- };
-
- static bool result;
- static IEntity first_item;
- }
-
- public class when_checking_if_there_are_changes_and_there_are_not : behaves_like_a_unit_of_work
- {
- it should_tell_the_truth = () => result.should_be_false();
-
- context c = () =>
- {
- first_item = an<IEntity>();
- var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
-
- when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
- when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(false);
- };
-
- because b = () =>
- {
- sut.register(first_item);
- result = sut.is_dirty();
- };
-
- static bool result;
- static IEntity first_item;
- }
+ //[Concern(typeof (unit_of_work<IEntity>))]
+ //public abstract class behaves_like_a_unit_of_work : concerns_for<IUnitOfWork<IEntity>, unit_of_work<IEntity>>
+ //{
+ // public override IUnitOfWork<IEntity> create_sut()
+ // {
+ // return new unit_of_work<IEntity>(repository, factory);
+ // }
+
+ // context c = () =>
+ // {
+ // repository = the_dependency<IDatabaseGateway>();
+ // factory = the_dependency<IUnitOfWorkRegistrationFactory<IEntity>>();
+ // };
+
+ // protected static IDatabaseGateway repository;
+ // protected static IUnitOfWorkRegistrationFactory<IEntity> factory;
+ //}
+
+ //public class when_committing_a_unit_of_work : behaves_like_a_unit_of_work
+ //{
+ // it should_save_each_registered_item = () =>
+ // {
+ // repository.was_told_to(x => x.save(first_item));
+ // repository.was_told_to(x => x.save(second_item));
+ // };
+
+ // context c = () =>
+ // {
+ // first_item = an<IEntity>();
+ // second_item = an<IEntity>();
+
+ // var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
+ // var second_registration = an<IUnitOfWorkRegistration<IEntity>>();
+
+ // when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
+ // when_the(factory).is_told_to(x => x.map_from(second_item)).it_will_return(
+ // second_registration);
+ // when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
+ // when_the(second_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
+ // when_the(first_registration).is_told_to(x => x.current).it_will_return(first_item);
+ // when_the(second_registration).is_told_to(x => x.current).it_will_return(second_item);
+ // };
+
+ // because b = () =>
+ // {
+ // sut.register(first_item);
+ // sut.register(second_item);
+ // sut.commit();
+ // };
+
+ // static IEntity first_item;
+ // static IEntity second_item;
+ //}
+
+ //public class when_checking_if_there_are_changes_and_there_are : behaves_like_a_unit_of_work
+ //{
+ // it should_tell_the_truth = () => result.should_be_true();
+
+ // context c = () =>
+ // {
+ // first_item = an<IEntity>();
+ // var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
+
+ // when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
+ // when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(true);
+ // when_the(first_registration).is_told_to(x => x.current).it_will_return(first_item);
+ // };
+
+ // because b = () =>
+ // {
+ // sut.register(first_item);
+ // result = sut.is_dirty();
+ // };
+
+ // static bool result;
+ // static IEntity first_item;
+ //}
+
+ //public class when_checking_if_there_are_changes_and_there_are_not : behaves_like_a_unit_of_work
+ //{
+ // it should_tell_the_truth = () => result.should_be_false();
+
+ // context c = () =>
+ // {
+ // first_item = an<IEntity>();
+ // var first_registration = an<IUnitOfWorkRegistration<IEntity>>();
+
+ // when_the(factory).is_told_to(x => x.map_from(first_item)).it_will_return(first_registration);
+ // when_the(first_registration).is_told_to(x => x.contains_changes()).it_will_return(false);
+ // };
+
+ // because b = () =>
+ // {
+ // sut.register(first_item);
+ // result = sut.is_dirty();
+ // };
+
+ // static bool result;
+ // static IEntity first_item;
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/UnitOfWork.cs
@@ -3,16 +3,16 @@ using MoMoney.Infrastructure.Container;
namespace MoMoney.Infrastructure.transactions
{
- public static class UnitOfWork
- {
- public static IUnitOfWork<T> For<T>() where T : IEntity
- {
- IUnitOfWork<T> unit_of_work = null;
- if (resolve.is_initialized())
- {
- unit_of_work = resolve.dependency_for<IUnitOfWorkRegistry>().start_unit_of_work_for<T>();
- }
- return unit_of_work ?? new NullUnitOfWork<T>();
- }
- }
+ //public static class UnitOfWork
+ //{
+ // public static IUnitOfWork<T> For<T>() where T : IEntity
+ // {
+ // IUnitOfWork<T> unit_of_work = null;
+ // if (resolve.is_initialized())
+ // {
+ // unit_of_work = resolve.dependency_for<IUnitOfWorkRegistry>().start_unit_of_work_for<T>();
+ // }
+ // return unit_of_work ?? new NullUnitOfWork<T>();
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/UnitOfWorkFactory.cs
@@ -4,25 +4,25 @@ using MoMoney.Infrastructure.Container;
namespace MoMoney.Infrastructure.transactions
{
- public interface IUnitOfWorkFactory
- {
- IUnitOfWork<T> create_for<T>() where T : IEntity;
- }
+ //public interface IUnitOfWorkFactory
+ //{
+ // IUnitOfWork<T> create_for<T>() where T : IEntity;
+ //}
- public class UnitOfWorkFactory : IUnitOfWorkFactory
- {
- readonly IDatabaseGateway repository;
- readonly IDependencyRegistry registry;
+ //public class UnitOfWorkFactory : IUnitOfWorkFactory
+ //{
+ // readonly IDatabaseGateway repository;
+ // readonly IDependencyRegistry registry;
- public UnitOfWorkFactory(IDatabaseGateway repository, IDependencyRegistry registry)
- {
- this.repository = repository;
- this.registry = registry;
- }
+ // public UnitOfWorkFactory(IDatabaseGateway repository, IDependencyRegistry registry)
+ // {
+ // this.repository = repository;
+ // this.registry = registry;
+ // }
- public IUnitOfWork<T> create_for<T>() where T : IEntity
- {
- return new unit_of_work<T>(repository, registry.get_a<IUnitOfWorkRegistrationFactory<T>>());
- }
- }
+ // public IUnitOfWork<T> create_for<T>() where T : IEntity
+ // {
+ // return new unit_of_work<T>(repository, registry.get_a<IUnitOfWorkRegistrationFactory<T>>());
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/UnitOfWorkRegistration.cs
@@ -2,42 +2,42 @@ using System.Reflection;
namespace MoMoney.Infrastructure.transactions
{
- public interface IUnitOfWorkRegistration<T>
- {
- T current { get; }
- bool contains_changes();
- }
+ //public interface IUnitOfWorkRegistration<T>
+ //{
+ // T current { get; }
+ // bool contains_changes();
+ //}
- public class UnitOfWorkRegistration<T> : IUnitOfWorkRegistration<T>
- {
- readonly T original;
+ //public class UnitOfWorkRegistration<T> : IUnitOfWorkRegistration<T>
+ //{
+ // readonly T original;
- public UnitOfWorkRegistration(T original, T current)
- {
- this.original = original;
- this.current = current;
- }
+ // public UnitOfWorkRegistration(T original, T current)
+ // {
+ // this.original = original;
+ // this.current = current;
+ // }
- public T current { get; set; }
+ // public T current { get; set; }
- public bool contains_changes()
- {
- var type = original.GetType();
- var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
- foreach (var field in fields)
- {
- var original_value = field.GetValue(original);
- var current_value = field.GetValue(current);
- if (original_value == null && current_value != null)
- {
- return true;
- }
- if (original_value != null && !original_value.Equals(current_value))
- {
- return true;
- }
- }
- return false;
- }
- }
+ // public bool contains_changes()
+ // {
+ // var type = original.GetType();
+ // var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
+ // foreach (var field in fields)
+ // {
+ // var original_value = field.GetValue(original);
+ // var current_value = field.GetValue(current);
+ // if (original_value == null && current_value != null)
+ // {
+ // return true;
+ // }
+ // if (original_value != null && !original_value.Equals(current_value))
+ // {
+ // return true;
+ // }
+ // }
+ // return false;
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/UnitOfWorkRegistrationFactory.cs
@@ -3,27 +3,27 @@ using MoMoney.Infrastructure.cloning;
namespace MoMoney.Infrastructure.transactions
{
- public interface IUnitOfWorkRegistrationFactory<T> : IMapper<T, IUnitOfWorkRegistration<T>>
- {
- }
+ //public interface IUnitOfWorkRegistrationFactory<T> : IMapper<T, IUnitOfWorkRegistration<T>>
+ //{
+ //}
- public class UnitOfWorkRegistrationFactory<T> : IUnitOfWorkRegistrationFactory<T>
- {
- readonly IPrototype prototype;
+ //public class UnitOfWorkRegistrationFactory<T> : IUnitOfWorkRegistrationFactory<T>
+ //{
+ // readonly IPrototype prototype;
- public UnitOfWorkRegistrationFactory(IPrototype prototype)
- {
- this.prototype = prototype;
- }
+ // public UnitOfWorkRegistrationFactory(IPrototype prototype)
+ // {
+ // this.prototype = prototype;
+ // }
- public IUnitOfWorkRegistration<T> map_from(T item)
- {
- return new UnitOfWorkRegistration<T>(create_prototype(item), item);
- }
+ // public IUnitOfWorkRegistration<T> map_from(T item)
+ // {
+ // return new UnitOfWorkRegistration<T>(create_prototype(item), item);
+ // }
- T create_prototype(T item)
- {
- return prototype.clone(item);
- }
- }
+ // T create_prototype(T item)
+ // {
+ // return prototype.clone(item);
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/UnitOfWorkRegistrationSpecs.cs
@@ -4,77 +4,77 @@ using MoMoney.Domain.Core;
namespace MoMoney.Infrastructure.transactions
{
- public abstract class behaves_like_unit_of_work_registration : concerns_for<IUnitOfWorkRegistration<Pillow>>
- {
- }
+ //public abstract class behaves_like_unit_of_work_registration : concerns_for<IUnitOfWorkRegistration<Pillow>>
+ //{
+ //}
- public class when_comparing_the_current_instance_of_a_component_with_its_original_and_it_has_changes :
- behaves_like_unit_of_work_registration
- {
- it should_indicate_that_there_are_changes = () => result.should_be_true();
+ //public class when_comparing_the_current_instance_of_a_component_with_its_original_and_it_has_changes :
+ // behaves_like_unit_of_work_registration
+ //{
+ // it should_indicate_that_there_are_changes = () => result.should_be_true();
- because b = () => { result = sut.contains_changes(); };
+ // because b = () => { result = sut.contains_changes(); };
- public override IUnitOfWorkRegistration<Pillow> create_sut()
- {
- return new UnitOfWorkRegistration<Pillow>(new Pillow("pink"), new Pillow("yellow"));
- }
+ // public override IUnitOfWorkRegistration<Pillow> create_sut()
+ // {
+ // return new UnitOfWorkRegistration<Pillow>(new Pillow("pink"), new Pillow("yellow"));
+ // }
- static bool result;
- }
+ // static bool result;
+ //}
- public class when_the_original_instance_has_a_null_field_that_is_now_not_null :
- behaves_like_unit_of_work_registration
- {
- it should_indicate_that_there_are_changes = () => result.should_be_true();
+ //public class when_the_original_instance_has_a_null_field_that_is_now_not_null :
+ // behaves_like_unit_of_work_registration
+ //{
+ // it should_indicate_that_there_are_changes = () => result.should_be_true();
- because b = () => { result = sut.contains_changes(); };
+ // because b = () => { result = sut.contains_changes(); };
- public override IUnitOfWorkRegistration<Pillow> create_sut()
- {
- return new UnitOfWorkRegistration<Pillow>(new Pillow(null), new Pillow("yellow"));
- }
+ // public override IUnitOfWorkRegistration<Pillow> create_sut()
+ // {
+ // return new UnitOfWorkRegistration<Pillow>(new Pillow(null), new Pillow("yellow"));
+ // }
- static bool result;
- }
+ // static bool result;
+ //}
- public class when_the_original_instance_had_a_non_null_field_and_the_current_instance_has_a_null_field :
- behaves_like_unit_of_work_registration
- {
- it should_indicate_that_there_are_changes = () => result.should_be_true();
+ //public class when_the_original_instance_had_a_non_null_field_and_the_current_instance_has_a_null_field :
+ // behaves_like_unit_of_work_registration
+ //{
+ // it should_indicate_that_there_are_changes = () => result.should_be_true();
- because b = () => { result = sut.contains_changes(); };
+ // because b = () => { result = sut.contains_changes(); };
- public override IUnitOfWorkRegistration<Pillow> create_sut()
- {
- return new UnitOfWorkRegistration<Pillow>(new Pillow("green"), new Pillow(null));
- }
+ // public override IUnitOfWorkRegistration<Pillow> create_sut()
+ // {
+ // return new UnitOfWorkRegistration<Pillow>(new Pillow("green"), new Pillow(null));
+ // }
- static bool result;
- }
+ // static bool result;
+ //}
- public class when_the_original_instance_has_the_same_value_as_the_current_instance :
- behaves_like_unit_of_work_registration
- {
- it should_indicate_that_there_are_no_changes = () => result.should_be_false();
+ //public class when_the_original_instance_has_the_same_value_as_the_current_instance :
+ // behaves_like_unit_of_work_registration
+ //{
+ // it should_indicate_that_there_are_no_changes = () => result.should_be_false();
- because b = () => { result = sut.contains_changes(); };
+ // because b = () => { result = sut.contains_changes(); };
- public override IUnitOfWorkRegistration<Pillow> create_sut()
- {
- return new UnitOfWorkRegistration<Pillow>(new Pillow("green"), new Pillow("green"));
- }
+ // public override IUnitOfWorkRegistration<Pillow> create_sut()
+ // {
+ // return new UnitOfWorkRegistration<Pillow>(new Pillow("green"), new Pillow("green"));
+ // }
- static bool result;
- }
+ // static bool result;
+ //}
- public class Pillow : Entity<Pillow>
- {
- readonly string color;
+ //public class Pillow : Entity<Pillow>
+ //{
+ // readonly string color;
- public Pillow(string color)
- {
- this.color = color;
- }
- }
+ // public Pillow(string color)
+ // {
+ // this.color = color;
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/UnitOfWorkRegistry.cs
@@ -6,63 +6,63 @@ using MoMoney.Domain.Core;
namespace MoMoney.Infrastructure.transactions
{
- public interface IUnitOfWorkRegistry : IDisposable
- {
- void commit_all();
- IUnitOfWork<T> start_unit_of_work_for<T>() where T : IEntity;
- bool has_changes_to_commit();
- }
+ //public interface IUnitOfWorkRegistry : IDisposable
+ //{
+ // void commit_all();
+ // IUnitOfWork<T> start_unit_of_work_for<T>() where T : IEntity;
+ // bool has_changes_to_commit();
+ //}
- public class UnitOfWorkRegistry : IUnitOfWorkRegistry
- {
- readonly IUnitOfWorkFactory factory;
- readonly IDictionary<Type, IUnitOfWork> units_of_work;
+ //public class UnitOfWorkRegistry : IUnitOfWorkRegistry
+ //{
+ // readonly IUnitOfWorkFactory factory;
+ // readonly IDictionary<Type, IUnitOfWork> units_of_work;
- public UnitOfWorkRegistry(IUnitOfWorkFactory factory)
- {
- this.factory = factory;
- units_of_work = new Dictionary<Type, IUnitOfWork>();
- }
+ // public UnitOfWorkRegistry(IUnitOfWorkFactory factory)
+ // {
+ // this.factory = factory;
+ // units_of_work = new Dictionary<Type, IUnitOfWork>();
+ // }
- public IUnitOfWork<T> start_unit_of_work_for<T>() where T : IEntity
- {
- if (units_of_work.ContainsKey(typeof (T)))
- {
- return units_of_work[typeof (T)].downcast_to<IUnitOfWork<T>>();
- }
+ // public IUnitOfWork<T> start_unit_of_work_for<T>() where T : IEntity
+ // {
+ // if (units_of_work.ContainsKey(typeof (T)))
+ // {
+ // return units_of_work[typeof (T)].downcast_to<IUnitOfWork<T>>();
+ // }
- var new_unit_of_work = factory.create_for<T>();
- units_of_work.Add(typeof (T), new_unit_of_work);
- return new_unit_of_work;
- }
+ // var new_unit_of_work = factory.create_for<T>();
+ // units_of_work.Add(typeof (T), new_unit_of_work);
+ // return new_unit_of_work;
+ // }
- public bool has_changes_to_commit()
- {
- return units_of_work.Values.Count(x => x.is_dirty()) > 0;
- }
+ // public bool has_changes_to_commit()
+ // {
+ // return units_of_work.Values.Count(x => x.is_dirty()) > 0;
+ // }
- public void commit_all()
- {
- if (contains_items_to_commit())
- {
- units_of_work.Values.each(x => x.commit());
- }
- }
+ // public void commit_all()
+ // {
+ // if (contains_items_to_commit())
+ // {
+ // units_of_work.Values.each(x => x.commit());
+ // }
+ // }
- void clear_all()
- {
- units_of_work.Values.each(x => x.Dispose());
- units_of_work.Clear();
- }
+ // void clear_all()
+ // {
+ // units_of_work.Values.each(x => x.Dispose());
+ // units_of_work.Clear();
+ // }
- bool contains_items_to_commit()
- {
- return units_of_work.Count > 0;
- }
+ // bool contains_items_to_commit()
+ // {
+ // return units_of_work.Count > 0;
+ // }
- public void Dispose()
- {
- clear_all();
- }
- }
+ // public void Dispose()
+ // {
+ // clear_all();
+ // }
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions/UnitOfWorkRegistrySpecs.cs
@@ -4,70 +4,70 @@ using MoMoney.Domain.Core;
namespace MoMoney.Infrastructure.transactions
{
- [Concern(typeof (UnitOfWorkRegistry))]
- public abstract class behaves_like_unit_of_work_registery : concerns_for<IUnitOfWorkRegistry, UnitOfWorkRegistry>
- {
- context c = () => { factory = the_dependency<IUnitOfWorkFactory>(); };
-
- static protected IUnitOfWorkFactory factory;
- }
-
- public class when_starting_a_unit_of_work_for_a_new_type : behaves_like_unit_of_work_registery
- {
- it should_register_a_new_unit_of_work = () => factory.was_told_to(x => x.create_for<IEntity>());
-
- it should_return_the_new_unit_of_work = () => result.should_be_equal_to(unit_of_work);
-
- context c = () =>
- {
- unit_of_work = an<IUnitOfWork<IEntity>>();
- factory.is_told_to(x => x.create_for<IEntity>()).it_will_return(unit_of_work);
- };
-
- because b = () => { result = sut.start_unit_of_work_for<IEntity>(); };
-
- static IUnitOfWork<IEntity> unit_of_work;
- static IUnitOfWork<IEntity> result;
- }
-
- public class when_attempting_to_start_a_unit_of_work_for_a_type_that_already_has_one_started :
- behaves_like_unit_of_work_registery
- {
- it should_return_the_already_started_unit_of_work = () => result.should_be_equal_to(unit_of_work);
-
- context c = () =>
- {
- unit_of_work = an<IUnitOfWork<IEntity>>();
-
- factory.is_told_to(x => x.create_for<IEntity>()).it_will_return(unit_of_work).Repeat.Once();
- };
-
- because b = () =>
- {
- sut.start_unit_of_work_for<IEntity>();
- result = sut.start_unit_of_work_for<IEntity>();
- };
-
- static IUnitOfWork<IEntity> unit_of_work;
- static IUnitOfWork<IEntity> result;
- }
-
- public class when_committing_all_the_active_units_of_work : behaves_like_unit_of_work_registery
- {
- it should_commit_each_one = () => unit_of_work.was_told_to(x => x.commit());
-
- context c = () =>
- {
- unit_of_work = an<IUnitOfWork<IEntity>>();
- factory.is_told_to(x => x.create_for<IEntity>()).it_will_return(unit_of_work).Repeat.Once();
- };
-
- because b = () =>
- {
- sut.start_unit_of_work_for<IEntity>();
- sut.commit_all();
- };
-
- static IUnitOfWork<IEntity> unit_of_work;
- }
+ //[Concern(typeof (UnitOfWorkRegistry))]
+ //public abstract class behaves_like_unit_of_work_registery : concerns_for<IUnitOfWorkRegistry, UnitOfWorkRegistry>
+ //{
+ // context c = () => { factory = the_dependency<IUnitOfWorkFactory>(); };
+
+ // static protected IUnitOfWorkFactory factory;
+ //}
+
+ //public class when_starting_a_unit_of_work_for_a_new_type : behaves_like_unit_of_work_registery
+ //{
+ // it should_register_a_new_unit_of_work = () => factory.was_told_to(x => x.create_for<IEntity>());
+
+ // it should_return_the_new_unit_of_work = () => result.should_be_equal_to(unit_of_work);
+
+ // context c = () =>
+ // {
+ // unit_of_work = an<IUnitOfWork<IEntity>>();
+ // factory.is_told_to(x => x.create_for<IEntity>()).it_will_return(unit_of_work);
+ // };
+
+ // because b = () => { result = sut.start_unit_of_work_for<IEntity>(); };
+
+ // static IUnitOfWork<IEntity> unit_of_work;
+ // static IUnitOfWork<IEntity> result;
+ //}
+
+ //public class when_attempting_to_start_a_unit_of_work_for_a_type_that_already_has_one_started :
+ // behaves_like_unit_of_work_registery
+ //{
+ // it should_return_the_already_started_unit_of_work = () => result.should_be_equal_to(unit_of_work);
+
+ // context c = () =>
+ // {
+ // unit_of_work = an<IUnitOfWork<IEntity>>();
+
+ // factory.is_told_to(x => x.create_for<IEntity>()).it_will_return(unit_of_work).Repeat.Once();
+ // };
+
+ // because b = () =>
+ // {
+ // sut.start_unit_of_work_for<IEntity>();
+ // result = sut.start_unit_of_work_for<IEntity>();
+ // };
+
+ // static IUnitOfWork<IEntity> unit_of_work;
+ // static IUnitOfWork<IEntity> result;
+ //}
+
+ //public class when_committing_all_the_active_units_of_work : behaves_like_unit_of_work_registery
+ //{
+ // it should_commit_each_one = () => unit_of_work.was_told_to(x => x.commit());
+
+ // context c = () =>
+ // {
+ // unit_of_work = an<IUnitOfWork<IEntity>>();
+ // factory.is_told_to(x => x.create_for<IEntity>()).it_will_return(unit_of_work).Repeat.Once();
+ // };
+
+ // because b = () =>
+ // {
+ // sut.start_unit_of_work_for<IEntity>();
+ // sut.commit_all();
+ // };
+
+ // static IUnitOfWork<IEntity> unit_of_work;
+ //}
}
\ No newline at end of file
trunk/product/MoMoney.Infrastructure/Transactions2/TrackerEntry.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using MoMoney.Infrastructure.Extensions;
namespace MoMoney.Infrastructure.transactions2
{
@@ -29,13 +30,16 @@ namespace MoMoney.Infrastructure.transactions2
var current_value = field.GetValue(current);
if (original_value == null && current_value != null)
{
+ this.log().debug("has changes: {0}", original);
return true;
}
if (original_value != null && !original_value.Equals(current_value))
{
+ this.log().debug("has changes: {0}", original);
return true;
}
}
+ this.log().debug("has no changes: {0}", original);
return false;
}
}
trunk/product/MoMoney.Infrastructure/Transactions2/UnitOfWorkInterceptor.cs
@@ -1,6 +1,7 @@
using Castle.Core.Interceptor;
+using Gorilla.Commons.Utility.Core;
using MoMoney.Infrastructure.eventing;
-//using MoMoney.Presentation.Model.messages;
+using MoMoney.Infrastructure.Extensions;
namespace MoMoney.Infrastructure.transactions2
{
@@ -23,12 +24,10 @@ namespace MoMoney.Infrastructure.transactions2
{
using (var unit_of_work = factory.create())
{
+ this.log().debug("intercepting: {0}", invocation);
invocation.Proceed();
- if (unit_of_work.is_dirty())
- {
- unit_of_work.commit();
- //broker.publish<UnsavedChangesEvent>();
- }
+ broker.publish<ICallback<IUnitOfWork>>(x => x.run(unit_of_work));
+ unit_of_work.commit();
}
}
}
trunk/product/MoMoney.Infrastructure/MoMoney.Infrastructure.csproj
@@ -125,7 +125,6 @@
<Compile Include="Interceptors\LoggingInterceptor.cs" />
<Compile Include="Interceptors\RaiseEventInterceptor.cs" />
<Compile Include="Interceptors\SynchronizedInterceptor.cs" />
- <Compile Include="Interceptors\UnitOfWorkInterceptor.cs" />
<Compile Include="Logging\ConsoleLogging\ConsoleLogger.cs" />
<Compile Include="Logging\ILogFactory.cs" />
<Compile Include="Logging\ILoggable.cs" />
@@ -209,18 +208,9 @@
<Compile Include="Transactions2\UnitOfWork.cs" />
<Compile Include="Transactions2\UnitOfWorkFactory.cs" />
<Compile Include="Transactions2\UnitOfWorkInterceptor.cs" />
- <Compile Include="Transactions\IDatabaseGateway.cs" />
- <Compile Include="Transactions\IUnitOfWorkRegistrationFactory.cs" />
- <Compile Include="Transactions\NullUnitOfWork.cs" />
- <Compile Include="Transactions\UnitOfWork.cs" />
- <Compile Include="Transactions\UnitOfWorkFactory.cs" />
- <Compile Include="Transactions\UnitOfWorkRegistration.cs" />
- <Compile Include="Transactions\UnitOfWorkRegistrationFactory.cs" />
- <Compile Include="Transactions\UnitOfWorkRegistrationSpecs.cs" />
- <Compile Include="Transactions\UnitOfWorkRegistry.cs" />
- <Compile Include="Transactions\UnitOfWorkRegistrySpecs.cs" />
- <Compile Include="Transactions\unit_of_work.cs" />
- <Compile Include="Transactions\unit_of_work_specs.cs" />
+ <Compile Include="Transactions\IDatabaseGateway.cs">
+ <SubType>Code</SubType>
+ </Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj">
trunk/product/MoMoney.Presentation/Model/Menu/MenuItem.cs
@@ -1,5 +1,6 @@
using System;
using System.Windows.Forms;
+using MoMoney.Infrastructure.Extensions;
using MoMoney.Presentation.Model.keyboard;
using MoMoney.Presentation.Resources;
@@ -48,6 +49,7 @@ namespace MoMoney.Presentation.Model.Menu
{
item.Enabled = can_be_clicked();
task_tray_item.Enabled = can_be_clicked();
+ //this.log().debug("item: {0}, is enabled: {1}", item.Text, item.Enabled);
}
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Model/Projects/EmptyProject.cs
@@ -0,0 +1,20 @@
+namespace MoMoney.Presentation.Model.Projects
+{
+ public class EmptyProject : IProject
+ {
+ public string name()
+ {
+ return "untitled.mo";
+ }
+
+ public bool is_file_specified()
+ {
+ return false;
+ }
+
+ public bool is_open()
+ {
+ return false;
+ }
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Model/Projects/Project.cs
@@ -0,0 +1,27 @@
+namespace MoMoney.Presentation.Model.Projects
+{
+ public class Project : IProject
+ {
+ readonly IFile file;
+
+ public Project(IFile file)
+ {
+ this.file = file;
+ }
+
+ public string name()
+ {
+ return is_file_specified() ? file.path : "untitled.mo";
+ }
+
+ public bool is_file_specified()
+ {
+ return file != null;
+ }
+
+ public bool is_open()
+ {
+ return true;
+ }
+ }
+}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Model/Projects/ProjectController.cs
@@ -1,11 +1,13 @@
+using Gorilla.Commons.Utility.Core;
using Gorilla.Commons.Utility.Extensions;
using MoMoney.Infrastructure.eventing;
+using MoMoney.Infrastructure.Extensions;
using MoMoney.Infrastructure.transactions2;
using MoMoney.Presentation.Model.messages;
namespace MoMoney.Presentation.Model.Projects
{
- public class ProjectController : IProjectController, IEventSubscriber<UnsavedChangesEvent>
+ public class ProjectController : IProjectController, ICallback<IUnitOfWork>
{
readonly IEventAggregator broker;
readonly IDatabaseConfiguration configuration;
@@ -84,52 +86,14 @@ namespace MoMoney.Presentation.Model.Projects
if (!has_been_saved_at_least_once()) throw new FileNotSpecifiedException();
}
- public void notify(UnsavedChangesEvent message)
+ public void run(IUnitOfWork item)
{
- unsaved_changes = true;
- }
- }
-
- public class EmptyProject : IProject
- {
- public string name()
- {
- return "untitled.mo";
- }
-
- public bool is_file_specified()
- {
- return false;
- }
-
- public bool is_open()
- {
- return false;
- }
- }
-
- public class Project : IProject
- {
- readonly IFile file;
-
- public Project(IFile file)
- {
- this.file = file;
- }
-
- public string name()
- {
- return is_file_specified() ? file.path : "untitled.mo";
- }
-
- public bool is_file_specified()
- {
- return file != null;
- }
-
- public bool is_open()
- {
- return true;
+ unsaved_changes = item.is_dirty();
+ if (unsaved_changes)
+ {
+ this.log().debug("unsaved changes: {0}", unsaved_changes);
+ broker.publish<UnsavedChangesEvent>();
+ }
}
}
}
\ No newline at end of file
trunk/product/MoMoney.Presentation/Model/Projects/ProjectControllerSpecs.cs
@@ -144,15 +144,20 @@ namespace MoMoney.Presentation.Model.Projects
{
it should_return_true = () => result.should_be_true();
- context c = () => { };
+ context c = () =>
+ {
+ unit_of_work = an<IUnitOfWork>();
+ when_the(unit_of_work).is_told_to(x => x.is_dirty()).it_will_return(true);
+ };
because b = () =>
{
- sut.downcast_to<ProjectController>().notify(new UnsavedChangesEvent());
+ sut.downcast_to<ProjectController>().run(unit_of_work);
result = sut.has_unsaved_changes();
};
static bool result;
+ static IUnitOfWork unit_of_work;
}
public class when_starting_a_new_project_and_a_project_was_already_open : behaves_like_a_project
trunk/product/MoMoney.Presentation/Presenters/Shell/TitleBarPresenter.cs
@@ -1,4 +1,5 @@
using MoMoney.Infrastructure.eventing;
+using MoMoney.Infrastructure.Extensions;
using MoMoney.Modules.Core;
using MoMoney.Presentation.Model.messages;
using MoMoney.Presentation.Model.Projects;
@@ -38,6 +39,7 @@ namespace MoMoney.Presentation.Presenters.Shell
public void notify(UnsavedChangesEvent dto)
{
+ this.log().debug("adding asterik");
view.append_asterik();
}
trunk/product/MoMoney.Presentation/Presenters/AddCompanyPresenter.cs
@@ -2,8 +2,8 @@ using System.Collections.Generic;
using System.Linq;
using Gorilla.Commons.Utility.Extensions;
using MoMoney.Domain.accounting.billing;
+using MoMoney.DTO;
using MoMoney.Presentation.Core;
-using MoMoney.Presentation.Presenters.billing.dto;
using MoMoney.Presentation.Views;
using MoMoney.Tasks.application;
using MoMoney.Tasks.infrastructure.core;
trunk/product/MoMoney.Presentation/Presenters/AddCompanyPresenterSpecs.cs
@@ -1,6 +1,6 @@
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Testing;
-using MoMoney.Presentation.Presenters.billing.dto;
+using MoMoney.DTO;
using MoMoney.Presentation.Views;
using MoMoney.Tasks.application;
using MoMoney.Tasks.infrastructure.core;
trunk/product/MoMoney.Presentation/Views/Core/ApplicationDockedWindow.Designer.cs
@@ -15,7 +15,7 @@ namespace MoMoney.Presentation.Views.core
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
- this.log().debug("disposing: {0}", this);
+ //this.log().debug("disposing: {0}", this);
if (disposing && (components != null))
{
components.Dispose();
trunk/product/MoMoney.Presentation/Views/Core/ApplicationWindow.cs
@@ -1,7 +1,6 @@
using System;
using System.ComponentModel;
using System.Windows.Forms;
-using MoMoney.Infrastructure.Extensions;
using MoMoney.Presentation.Resources;
using MoMoney.Presentation.Views.helpers;
@@ -21,7 +20,7 @@ namespace MoMoney.Presentation.Views.core
{
InitializeComponent();
Icon = ApplicationIcons.Application;
- this.log().debug("created {0}", GetType());
+ //this.log().debug("created {0}", GetType());
on_activated = x => { };
on_deactivate = x => { };
trunk/product/MoMoney.Presentation/Views/AddCompanyView.cs
@@ -5,10 +5,10 @@ using System.Text;
using System.Windows.Forms;
using Gorilla.Commons.Utility.Extensions;
using MoMoney.Domain.accounting.billing;
+using MoMoney.DTO;
using MoMoney.Presentation.Databindings;
using MoMoney.Presentation.Model.interaction;
using MoMoney.Presentation.Presenters;
-using MoMoney.Presentation.Presenters.billing.dto;
using MoMoney.Presentation.Resources;
using MoMoney.Presentation.Views.core;
trunk/product/MoMoney.Presentation/MoMoney.Presentation.csproj
@@ -161,9 +161,11 @@
<Compile Include="Model\Navigation\tree_branch_specs.cs" />
<Compile Include="Model\Navigation\view_all_bills_branch.cs" />
<Compile Include="Model\Navigation\view_all_bills_report_branch.cs" />
+ <Compile Include="Model\Projects\EmptyProject.cs" />
<Compile Include="Model\Projects\file_not_specified_exception.cs" />
<Compile Include="Model\Projects\IProject.cs" />
<Compile Include="Model\Projects\IProjectController.cs" />
+ <Compile Include="Model\Projects\Project.cs" />
<Compile Include="Model\Projects\ProjectController.cs" />
<Compile Include="Model\Projects\ProjectControllerSpecs.cs" />
<Compile Include="Model\Reporting\IReport.cs" />
trunk/product/MoMoney.Service/Application/CustomerTasks.cs
@@ -1,6 +1,7 @@
using System.Linq;
using MoMoney.DataAccess.core;
using MoMoney.Domain.accounting;
+using MoMoney.Domain.repositories;
namespace MoMoney.Tasks.application
{
@@ -11,21 +12,21 @@ namespace MoMoney.Tasks.application
public class CustomerTasks : ICustomerTasks
{
- readonly IDatabaseGateway repository;
+ IAccountHolderRepository account_holders;
- public CustomerTasks(IDatabaseGateway repository)
+ public CustomerTasks( IAccountHolderRepository account_holders)
{
- this.repository = repository;
+ this.account_holders = account_holders;
}
public IAccountHolder get_the_current_customer()
{
- var c = repository.all<IAccountHolder>().SingleOrDefault();
+ var c = account_holders.all().SingleOrDefault();
if (null == c)
{
var customer = new AccountHolder();
- repository.save(customer);
+ account_holders.save(customer);
return customer;
}
trunk/product/MoMoney.Service/Application/RegisterNewCompanyCommand.cs
@@ -1,6 +1,6 @@
using Gorilla.Commons.Utility.Core;
using MoMoney.Domain.accounting.billing;
-using MoMoney.Presentation.Presenters.billing.dto;
+using MoMoney.DTO;
namespace MoMoney.Tasks.application
{
trunk/product/MyMoney/boot/container/registration/wire_up_the_data_access_components_into_the.cs
@@ -1,6 +1,5 @@
using Gorilla.Commons.Utility.Core;
using Gorilla.Commons.Utility.Extensions;
-using MoMoney.DataAccess.db40;
using MoMoney.Infrastructure.Container;
using MoMoney.Infrastructure.transactions2;
@@ -17,9 +16,10 @@ namespace MoMoney.boot.container.registration
public void run()
{
- register.singleton<ISessionContext, SessionContext>();
+ //register.singleton<ISessionContext, SessionContext>();
register.singleton<IDatabase, Database>();
register.singleton(() => resolve.dependency_for<IDatabase>().downcast_to<IDatabaseConfiguration>());
+ register.singleton<ISession>(() => resolve.dependency_for<ISessionProvider>().get_the_current_session());
}
}
}
\ No newline at end of file
trunk/product/MyMoney/boot/container/registration/wire_up_the_infrastructure_in_to_the.cs
@@ -3,7 +3,7 @@ using MoMoney.Infrastructure.Container;
using MoMoney.Infrastructure.eventing;
using MoMoney.Infrastructure.registries;
using MoMoney.Infrastructure.Threading;
-using MoMoney.Infrastructure.transactions;
+//using MoMoney.Infrastructure.transactions;
using MoMoney.Infrastructure.transactions2;
using MoMoney.Presentation.Model.Projects;
@@ -22,10 +22,10 @@ namespace MoMoney.boot.container.registration
{
registry.singleton<IEventAggregator, EventAggregator>();
registry.singleton<ITimer, IntervalTimer>();
- registry.singleton<IUnitOfWorkRegistry, UnitOfWorkRegistry>();
+ //registry.singleton<IUnitOfWorkRegistry, UnitOfWorkRegistry>();
registry.singleton<IProjectController, ProjectController>();
registry.transient(typeof (IRegistry<>), typeof (DefaultRegistry<>));
- registry.transient(typeof (IUnitOfWorkRegistrationFactory<>), typeof (UnitOfWorkRegistrationFactory<>));
+ //registry.transient(typeof (IUnitOfWorkRegistrationFactory<>), typeof (UnitOfWorkRegistrationFactory<>));
registry.transient(typeof (ITrackerEntryMapper<>), typeof (TrackerEntryMapper<>));
registry.transient(typeof (IKey<>), typeof (TypedKey<>));
trunk/product/MyMoney/boot/container/registration/wire_up_the_services_in_to_the.cs
@@ -25,7 +25,7 @@ namespace MoMoney.boot.container.registration
() => new BillingTasks(Lazy.load<IBillRepository>(), Lazy.load<ICompanyRepository>()));
registry.proxy<ICustomerTasks, ServiceLayerConfiguration<ICustomerTasks>>(
- () => new CustomerTasks(Lazy.load<IDatabaseGateway>()));
+ () => new CustomerTasks(Lazy.load<IAccountHolderRepository>()));
registry.proxy<IIncomeTasks, ServiceLayerConfiguration<IIncomeTasks>>(
() => new IncomeTasks(Lazy.load<ICustomerTasks>(),