├── .gitignore ├── Fohjin.DDD.Example ├── Fohjin.DDD.BankApplication │ ├── ApplicationBootStrapper.cs │ ├── ApplicationRegistry.cs │ ├── Fohjin.DDD.BankApplication.csproj │ ├── Presenters │ │ ├── AccountDetailsPresenter.cs │ │ ├── ClientDetailsPresenter.cs │ │ ├── ClientSearchFormPresenter.cs │ │ ├── IAccountDetailsPresenter.cs │ │ ├── IClientDetailsPresenter.cs │ │ ├── IClientSearchFormPresenter.cs │ │ ├── IPopupPresenter.cs │ │ ├── IPresenter.cs │ │ └── PopupPresenter.cs │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── Views │ │ ├── AccountDetails.Designer.cs │ │ ├── AccountDetails.cs │ │ ├── AccountDetails.resx │ │ ├── ActionDelegate.cs │ │ ├── ClientDetails.Designer.cs │ │ ├── ClientDetails.cs │ │ ├── ClientDetails.resx │ │ ├── ClientSearchForm.Designer.cs │ │ ├── ClientSearchForm.cs │ │ ├── ClientSearchForm.resx │ │ ├── IAccountDetailsView.cs │ │ ├── IClientDetailsView.cs │ │ ├── IClientSearchFormView.cs │ │ ├── IPopupView.cs │ │ ├── IView.cs │ │ ├── Popup.Designer.cs │ │ ├── Popup.cs │ │ └── Popup.resx ├── Fohjin.DDD.Bus │ ├── Direct │ │ ├── DirectBus.cs │ │ ├── IRouteMessages.cs │ │ ├── InMemoryQueue.cs │ │ └── RouteNotRegisteredException.cs │ ├── Fohjin.DDD.Bus.csproj │ ├── IBus.cs │ ├── IUnitOfWork.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Fohjin.DDD.CommandHandlers │ ├── AssignNewBankCardCommandHandler.cs │ ├── CancelBankCardCommandHandler.cs │ ├── ChangeAccountNameCommandHandler.cs │ ├── ChangeClientNameCommandHandler.cs │ ├── ChangeClientPhoneNumberCommandHandler.cs │ ├── ClientIsMovingCommandHandler.cs │ ├── CloseAnAccountCommandHandler.cs │ ├── CreateClientCommandHandler.cs │ ├── DepositeCashCommandHandler.cs │ ├── Fohjin.DDD.CommandHandlers.csproj │ ├── ICommandHandler.cs │ ├── MoneyTransferFailedCompensatingCommandHandler.cs │ ├── OpenNewAccountForClientCommandHandler.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ReceiveMoneyTransferCommandHandler.cs │ ├── ReportStolenBankCardCommandHandler.cs │ ├── SendMoneyTransferCommandHandler.cs │ ├── TransactionHandler.cs │ └── WithdrawlCashCommandHandler.cs ├── Fohjin.DDD.Commands │ ├── AssignNewBankCardCommand.cs │ ├── CancelBankCardCommand.cs │ ├── ChangeAccountNameCommand.cs │ ├── ChangeClientNameCommand.cs │ ├── ChangeClientPhoneNumberCommand.cs │ ├── ClientIsMovingCommand.cs │ ├── CloseAccountCommand.cs │ ├── Command.cs │ ├── CreateClientCommand.cs │ ├── DepositeCashCommand.cs │ ├── Fohjin.DDD.Commands.csproj │ ├── ICommand.cs │ ├── MoneyTransferFailedCompensatingCommand.cs │ ├── OpenNewAccountForClientCommand.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ReceiveMoneyTransferCommand.cs │ ├── ReportStolenBankCardCommand.cs │ ├── SendMoneyTransferCommand.cs │ └── WithdrawlCashCommand.cs ├── Fohjin.DDD.Configuration │ ├── CommandHandlerHelper.cs │ ├── DomainDatabaseBootStrapper.cs │ ├── DomainRegistry.cs │ ├── EventHandlerHelper.cs │ ├── Fohjin.DDD.Configuration.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RegisterCommandHandlersInMessageRouter.cs │ ├── RegisterEventHandlersInMessageRouter.cs │ ├── ReportingDatabaseBootStrapper.cs │ └── ReportingRegistry.cs ├── Fohjin.DDD.Domain │ ├── Account │ │ ├── AccountBalanceNotZeroException.cs │ │ ├── AccountBalanceToLowException.cs │ │ ├── AccountName.cs │ │ ├── AccountNumber.cs │ │ ├── ActiveAccount.cs │ │ ├── Amount.cs │ │ ├── Balance.cs │ │ ├── ClosedAccount.cs │ │ ├── ClosedAccountException.cs │ │ ├── Ledger.cs │ │ └── NonExitsingAccountException.cs │ ├── Client │ │ ├── Address.cs │ │ ├── BankCard.cs │ │ ├── BankCardIsDisabledException.cs │ │ ├── Client.cs │ │ ├── ClientName.cs │ │ ├── IBankCard.cs │ │ ├── NonExistingAccountException.cs │ │ ├── NonExistingBankCardException.cs │ │ ├── NonExistingClientException.cs │ │ └── PhoneNumber.cs │ ├── Fohjin.DDD.Domain.csproj │ ├── Mementos │ │ ├── ActiveAccountMemento.cs │ │ ├── BankCardMemento.cs │ │ ├── ClientMemento.cs │ │ └── ClosedAccountMemento.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Fohjin.DDD.EventHandlers │ ├── AccountClosedEventHandler.cs │ ├── AccountNameChangedEventHandler.cs │ ├── AccountOpenedEventHandler.cs │ ├── AccountToClientAssignedEventHandler.cs │ ├── BankCardWasCanceledByCLientEventHandler.cs │ ├── BankCardWasReportedStolenEventHandler.cs │ ├── CashDepositeEventHandler.cs │ ├── CashWithdrawnEventHandler.cs │ ├── ClientCreatedEventHandler.cs │ ├── ClientMovedEventHandler.cs │ ├── ClientNameChangedEventHandler.cs │ ├── ClientPhoneNumberChangedEventHandler.cs │ ├── ClosedAccountCreatedEventHandler.cs │ ├── Fohjin.DDD.EventHandlers.csproj │ ├── IEventHandler.cs │ ├── MoneyTransferFailedEventHandler.cs │ ├── MoneyTransferReceivedEventHandler.cs │ ├── MoneyTransferSendEventHandler.cs │ ├── NewBankCardForAccountAssignedEventHandler.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SendMoneyTransferFurtherEventHandler.cs ├── Fohjin.DDD.EventStore.SQLite │ ├── ConcurrencyViolationException.cs │ ├── DomainEventStorage.cs │ ├── Fohjin.DDD.EventStore.SQLite.csproj │ └── Properties │ │ └── AssemblyInfo.cs ├── Fohjin.DDD.EventStore │ ├── Aggregate │ │ ├── BaseAggregateRoot.cs │ │ ├── BaseEntity.cs │ │ ├── BaseEntityExtensions.cs │ │ ├── EntityList.cs │ │ └── UnregisteredDomainEventException.cs │ ├── DomainRepository.cs │ ├── Fohjin.DDD.EventStore.csproj │ ├── IDomainEvent.cs │ ├── IDomainRepository.cs │ ├── IEntityEventProvider.cs │ ├── IEventProvider.cs │ ├── IRegisterChildEntities.cs │ ├── ITransactional.cs │ ├── IUnitOfWork.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Storage │ │ ├── EventStoreIdentityMap.cs │ │ ├── EventStoreUnitOfWork.cs │ │ ├── IDomainEventStorage.cs │ │ ├── IEventStoreUnitOfWork.cs │ │ ├── IIdentityMap.cs │ │ ├── ISnapShot.cs │ │ ├── ISnapShotStorage.cs │ │ ├── Memento │ │ ├── IMomento.cs │ │ └── IOrginator.cs │ │ └── SnapShot.cs ├── Fohjin.DDD.Events │ ├── Account │ │ ├── AccountClosedEvent.cs │ │ ├── AccountNameChangedEvent.cs │ │ ├── AccountOpenedEvent.cs │ │ ├── CashDepositedEvent.cs │ │ ├── CashWithdrawnEvent.cs │ │ ├── ClosedAccountCreatedEvent.cs │ │ ├── MoneyTransferFailedEvent.cs │ │ ├── MoneyTransferReceivedEvent.cs │ │ └── MoneyTransferSendEvent.cs │ ├── Client │ │ ├── AccountToClientAssignedEvent.cs │ │ ├── BankCardWasCanceledByCLientEvent.cs │ │ ├── BankCardWasReportedStolenEvent.cs │ │ ├── ClientCreatedEvent.cs │ │ ├── ClientMovedEvent.cs │ │ ├── ClientNameChangedEvent.cs │ │ ├── ClientPhoneNumberChangedEvent.cs │ │ └── NewBankCardForAccountAsignedEvent.cs │ ├── DomainEvent.cs │ ├── Fohjin.DDD.Events.csproj │ └── Properties │ │ └── AssemblyInfo.cs ├── Fohjin.DDD.Reporting.Dto │ ├── AccountDetailsReport.cs │ ├── AccountReport.cs │ ├── ClientDetailsReport.cs │ ├── ClientReport.cs │ ├── ClosedAccountDetailsReport.cs │ ├── ClosedAccountReport.cs │ ├── Fohjin.DDD.Reporting.Dto.csproj │ ├── LedgerReport.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Fohjin.DDD.Reporting │ ├── Fohjin.DDD.Reporting.csproj │ ├── IReportingRepository.cs │ ├── Infrastructure │ │ ├── SQLiteReportingRepository.cs │ │ ├── SqlCreateBuilder.cs │ │ ├── SqlDeleteBuilder.cs │ │ ├── SqlInsertBuilder.cs │ │ ├── SqlSelectBuilder.cs │ │ └── SqlUpdateBuilder.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Fohjin.DDD.Services │ ├── Fohjin.DDD.Services.csproj │ ├── MoneyReceiveService.cs │ ├── MoneyTransfer.cs │ ├── MoneyTransferService.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ServicesRegister.cs │ └── UnknownAccountException.cs ├── Fohjin.DDD.sln ├── Fohjin │ ├── Fohjin.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SystemDateTime.cs │ ├── SystemRandom.cs │ └── SystemTimer.cs ├── Lib │ ├── Moq │ │ ├── Moq.Contrib.dll │ │ ├── Moq.Contrib.pdb │ │ ├── Moq.dll │ │ ├── Moq.pdb │ │ └── Moq.xml │ ├── NUnit │ │ ├── nunit.core.dll │ │ ├── nunit.core.extensions.dll │ │ ├── nunit.core.interfaces.dll │ │ ├── nunit.framework.dll │ │ └── nunit.util.dll │ ├── StructureMap │ │ ├── StructureMap.AutoMocking.dll │ │ ├── StructureMap.dll │ │ └── StructureMap.pdb │ └── sqlite │ │ ├── bin │ │ ├── CompactFramework │ │ │ ├── SQLite.Interop.065.DLL │ │ │ ├── SQLite.Interop.065.exp │ │ │ ├── SQLite.Interop.065.lib │ │ │ ├── System.Data.SQLite.dll │ │ │ └── testce.exe │ │ ├── Designer │ │ │ ├── SQLite.Designer.dll │ │ │ ├── install.exe │ │ │ └── install.exe.config │ │ ├── ManagedOnly │ │ │ ├── System.Data.SQLite.dll │ │ │ ├── readme.txt │ │ │ ├── test.exe │ │ │ └── test.exe.config │ │ ├── System.Data.SQLite.DLL │ │ ├── System.Data.SQLite.Linq.dll │ │ ├── System.Data.SQLite.exp │ │ ├── System.Data.SQLite.lib │ │ ├── itanium │ │ │ ├── System.Data.SQLite.DLL │ │ │ ├── System.Data.SQLite.exp │ │ │ ├── System.Data.SQLite.lib │ │ │ ├── test.exe │ │ │ └── test.exe.config │ │ ├── linq │ │ │ ├── northwindEF.db │ │ │ ├── testlinq.exe │ │ │ └── testlinq.exe.config │ │ ├── test.exe │ │ ├── test.exe.config │ │ └── x64 │ │ │ ├── System.Data.SQLite.DLL │ │ │ ├── System.Data.SQLite.exp │ │ │ ├── System.Data.SQLite.lib │ │ │ ├── test.exe │ │ │ └── test.exe.config │ │ ├── sqlite3.exe │ │ └── sqlite3_analyzer.exe ├── ReadMe.txt └── Test.Fohjin.DDD │ ├── AggregateRootTestFixture.cs │ ├── BaseTestFixture.cs │ ├── Bus │ ├── Command_bus.cs │ └── Event_bus.cs │ ├── CommandTestFixture.cs │ ├── Commands │ ├── All_commands_must_be_Serializable.cs │ └── All_commands_must_have_a_handler.cs │ ├── Configuration │ ├── ApplicationBootStrapperTest.cs │ ├── DatabaseBootStrapperTest.cs │ ├── ReportingBootStrapperTest.cs │ └── StructureMapTest.cs │ ├── Domain │ ├── BaseAggregateTest.cs │ └── Repositories │ │ ├── ActiveAccountRepositoryTest.cs │ │ ├── ClientRepositoryTest.cs │ │ └── ClosedAccountRepositoryTest.cs │ ├── EventTestFixture.cs │ ├── Events │ ├── All_domain_events_must_be_Serializable.cs │ └── All_domain_events_must_have_a_handler.cs │ ├── Presenter │ └── PresenterTest.cs │ ├── PresenterTestFixture.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Queueing │ └── InMemoryQueue_test.cs │ ├── Reporting │ └── Infrastructure │ │ ├── RepositoryTest.cs │ │ ├── SqlCreateBuilderTest.cs │ │ ├── SqlDeleteBuilderTest.cs │ │ ├── SqlInsertBuilderTest.cs │ │ ├── SqlSelectBuilderTest.cs │ │ ├── SqlUpdateBuilderTest.cs │ │ └── TestDtoCase1.cs │ ├── Scenarios │ ├── Adding_a_new_client │ │ ├── When_creating_a_new_client.cs │ │ ├── When_in_the_GUI_adding_a_new_client.cs │ │ ├── When_in_the_GUI_canceling_to_add_the_new_client.cs │ │ ├── When_in_the_GUI_the_address_of_the_new_client_is_saved.cs │ │ ├── When_in_the_GUI_the_name_of_the_new_client_is_saved.cs │ │ ├── When_in_the_GUI_the_new_client_form_is_displayed_.cs │ │ ├── When_in_the_GUI_the_phone_number_of_the_new_client_is_saved.cs │ │ └── When_the_new_client_was_created.cs │ ├── Assign_new_bank_card │ │ ├── When_assigning_a_new_bank_card.cs │ │ ├── When_assigning_a_new_bank_card_on_a_non_existing_client.cs │ │ ├── When_canceling_a_bank_card.cs │ │ ├── When_canceling_a_disabled_bank_card.cs │ │ ├── When_canceling_a_non_existing_bank_card.cs │ │ ├── When_reporting_a_bank_card_stolen.cs │ │ ├── When_reporting_a_disabled_bank_card_stolen.cs │ │ └── When_reporting_a_non_existing_bank_card_stolen.cs │ ├── Changing_the_name_of_an_account │ │ ├── When_an_account_name_was_changed.cs │ │ ├── When_changing_the_name_of_a_closed_account.cs │ │ ├── When_changing_the_name_of_a_non_existing_account.cs │ │ ├── When_changing_the_name_of_an_account.cs │ │ ├── When_in_the_GUI_canceling_to_change_account_name.cs │ │ ├── When_in_the_GUI_changing_an_account_name.cs │ │ ├── When_in_the_GUI_clearing_the_new_name.cs │ │ ├── When_in_the_GUI_inserting_the_new_name.cs │ │ └── When_in_the_GUI_saving_the_new_name.cs │ ├── Client_got_a_new_phone_number │ │ ├── When_a_client_phone_number_was_changed.cs │ │ ├── When_changing_the_phone_number.cs │ │ ├── When_changing_the_phone_number_of_a_non_existing_client.cs │ │ ├── When_in_the_GUI_changing_a_clients_phone_number.cs │ │ ├── When_in_the_GUI_clearing_the_new_phone_number.cs │ │ ├── When_in_the_GUI_inserting_the_new_phone_number.cs │ │ └── When_in_the_GUI_saving_the_new_phone_number.cs │ ├── Client_got_his_name_changed │ │ ├── When_a_client_name_was_changed.cs │ │ ├── When_changing_the_name_of_a_client.cs │ │ ├── When_changing_the_name_of_a_non_existing_client.cs │ │ ├── When_in_the_GUI_canceling_the_changing_of_the_client_name.cs │ │ ├── When_in_the_GUI_changing_the_name_of_a_client.cs │ │ ├── When_in_the_GUI_clearing_the_new_client_name.cs │ │ ├── When_in_the_GUI_inserting_the_new_client_name.cs │ │ └── When_in_the_GUI_saving_the_new_client_name.cs │ ├── Client_moved │ │ ├── When_a_client_is_moving.cs │ │ ├── When_a_non_existing_client_is_moving.cs │ │ ├── When_client_has_moved.cs │ │ ├── When_in_the_GUI_a_client_is_moving_.cs │ │ ├── When_in_the_GUI_clearing_the_new_address.cs │ │ ├── When_in_the_GUI_inserting_the_new_address.cs │ │ └── When_in_the_GUI_saving_the_new_address.cs │ ├── Client_wants_to_close_an_account │ │ ├── When_an_account_was_closed.cs │ │ ├── When_an_closed_account_was_created.cs │ │ ├── When_closing_a_closed_account.cs │ │ ├── When_closing_a_non_existing_account.cs │ │ ├── When_closing_an_account.cs │ │ ├── When_closing_an_account_with_a_positive_balance.cs │ │ ├── When_creating_a_closed_account.cs │ │ └── When_in_the_GUI_closing_an_account.cs │ ├── Client_wants_to_open_a_new_account │ │ ├── When_an_account_was_assigned_to_a_client.cs │ │ ├── When_an_account_was_opened.cs │ │ ├── When_creating_a_new_account.cs │ │ ├── When_in_the_GUI_canceling_the_opening_of_a_new_account.cs │ │ ├── When_in_the_GUI_opening_a_new_account.cs │ │ ├── When_in_the_GUI_saving_the_new_account.cs │ │ ├── When_opening_a_new_account.cs │ │ └── When_opening_a_new_account_for_a_non_existing_client.cs │ ├── Depositing_cash │ │ ├── When_cash_was_deposited.cs │ │ ├── When_depositing_cash.cs │ │ ├── When_depositing_cash_on_a_closed_account.cs │ │ ├── When_depositing_cash_on_a_non_existing_account.cs │ │ ├── When_in_the_GUI_canceling_to_make_a_cash_deposite.cs │ │ ├── When_in_the_GUI_clearing_the_deposite_ammount.cs │ │ ├── When_in_the_GUI_executing_the_cash_deposite.cs │ │ ├── When_in_the_GUI_inserting_the_deposite_ammount.cs │ │ └── When_in_the_GUI_making_a_cash_deposite.cs │ ├── Displaying_account_details │ │ ├── When_in_the_GUI_displaying_account_details.cs │ │ └── When_in_the_GUI_opening_an_existing_account.cs │ ├── Displaying_client_details │ │ ├── When_in_the_GUI_displaying_client_details.cs │ │ └── When_in_the_GUI_opening_an_existing_client.cs │ ├── Displaying_the_error_popup │ │ └── When_in_the_GUI_displaying_the_error_popup.cs │ ├── Opening_the_bank_application │ │ └── Opening_the_application.cs │ ├── Receiving_money_transfer │ │ ├── When_a_money_transfer_was_received.cs │ │ ├── When_receiveing_a_money_transfer.cs │ │ ├── When_receiveing_a_money_transfer_for_a_closed_account.cs │ │ ├── When_receiveing_a_money_transfer_for_a_non_existing_account.cs │ │ ├── When_receiving_a_money_transfer.cs │ │ └── When_receiving_a_money_transfer_for_an_unknown_account.cs │ ├── Transfering_money │ │ ├── When_compensating_a_failed_money_transfer.cs │ │ ├── When_compensating_a_failed_money_transfer_from_a_closed_account.cs │ │ ├── When_compensating_a_failed_money_transfer_from_a_non_existing_account.cs │ │ ├── When_failing_to_transfer_money_to_an_external_account.cs │ │ ├── When_failing_to_transfer_money_to_an_internal_account.cs │ │ ├── When_in_the_GUI_canceling_to_make_a_money_transfer.cs │ │ ├── When_in_the_GUI_clearing_the_transfer_ammount.cs │ │ ├── When_in_the_GUI_executing_the_money_transfer.cs │ │ ├── When_in_the_GUI_inserting_the_transfer_ammount.cs │ │ ├── When_in_the_GUI_making_a_money_transfer.cs │ │ ├── When_money_transfer_failed.cs │ │ ├── When_money_transfer_was_send.cs │ │ ├── When_money_transfer_was_send_further.cs │ │ ├── When_sending_a_money_transfer.cs │ │ ├── When_sending_a_money_transfer_from_a_closed_account.cs │ │ ├── When_sending_a_money_transfer_from_a_non_existing_account.cs │ │ ├── When_sending_a_money_transfer_from_an_account_with_to_little_balance.cs │ │ ├── When_transfering_money_to_an_external_account.cs │ │ └── When_transfering_money_to_an_internal_account.cs │ └── Withdrawing_cash │ │ ├── When_cash_was_withdrawn.cs │ │ ├── When_in_the_GUI_canceling_to_make_a_cash_withdrawl.cs │ │ ├── When_in_the_GUI_clearing_the_withdrawl_ammount.cs │ │ ├── When_in_the_GUI_executing_the_cash_withdrawl.cs │ │ ├── When_in_the_GUI_inserting_the_withdrawl_ammount.cs │ │ ├── When_in_the_GUI_making_a_cash_withdrawl.cs │ │ ├── When_withdrawing_cash.cs │ │ ├── When_withdrawling_cash_from_a_closed_account.cs │ │ ├── When_withdrawling_cash_from_a_non_existing_account.cs │ │ └── When_withdrawling_cash_from_an_account_account_with_to_little_balance.cs │ ├── Test.Fohjin.DDD.csproj │ └── TestExtensions.cs ├── Fohjin.DDD.MakeReusable ├── Fohjin.EventStore │ ├── Fohjin.EventStore.sln │ ├── Fohjin.EventStore │ │ ├── Configuration │ │ │ ├── ApprovedEntitiesCache.cs │ │ │ ├── EventProcessor.cs │ │ │ ├── EventProcessorCache.cs │ │ │ ├── MethodMissingException.cs │ │ │ └── PreProcessor.cs │ │ ├── Fohjin.EventStore.csproj │ │ ├── IDomainEvent.cs │ │ ├── IDomainRepository.cs │ │ ├── IMemento.cs │ │ ├── Infrastructure │ │ │ ├── IAggregateRootFactory.cs │ │ │ ├── IEventProvider.cs │ │ │ ├── IOrginator.cs │ │ │ ├── IlligalStateAssignmentException.cs │ │ │ └── UnregisteredDomainEventException.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── Reflection │ │ │ ├── EventAccessor.cs │ │ │ └── EventPropertyLocator.cs │ └── Test.Fohjin.EventStore │ │ ├── BaseTestFixture.cs │ │ ├── Configuration │ │ └── When_registering_an_domain_event.cs │ │ ├── Infrastructure │ │ ├── When_an_event_gets_published.cs │ │ ├── When_an_unregistered_event_gets_published.cs │ │ ├── When_executing_behavior_that_diretly_sets_the_internal_state.cs │ │ ├── When_instantiating_an_aggregate_root_it_will_wire_the_events_correctly.cs │ │ ├── When_instantiating_two_of_the_same_aggregate_roots_it_will_wire_the_events_correctly_without_mixing_them_together.cs │ │ ├── When_loading_an_empty_history_event_collection.cs │ │ ├── When_loading_an_history_event_collection_containing_one_event.cs │ │ ├── When_loading_an_history_event_collection_containing_two_event.cs │ │ ├── When_multiple_events_gets_published.cs │ │ ├── When_requesting_a_new_object_from_the_repository.cs │ │ ├── When_requesting_a_new_object_from_the_repository_that_has_no_virtual_apply_method.cs │ │ ├── When_the_internal_collection_of_published_events_gets_cleared.cs │ │ └── When_updating_the_version.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── Test.Fohjin.EventStore.csproj │ │ ├── TestClient.cs │ │ └── TestExtensions.cs └── Lib │ ├── CastleDynamicProxy │ ├── Castle.Core.dll │ ├── Castle.Core.pdb │ ├── Castle.DynamicProxy2.dll │ └── Castle.DynamicProxy2.pdb │ ├── Moq │ ├── Moq.Contrib.dll │ ├── Moq.Contrib.pdb │ ├── Moq.dll │ └── Moq.pdb │ ├── NUnit │ ├── nunit.core.dll │ ├── nunit.core.extensions.dll │ ├── nunit.core.interfaces.dll │ ├── nunit.framework.dll │ └── nunit.util.dll │ ├── StructureMap │ ├── StructureMap.AutoMocking.dll │ ├── StructureMap.dll │ └── StructureMap.pdb │ └── sqlite │ ├── sqlite3.exe │ └── sqlite3_analyzer.exe └── ReadMe.txt /.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | bin 3 | _ReSharper.* 4 | *.csproj.user 5 | *.resharper.user 6 | *.resharper 7 | *.suo 8 | *.cache 9 | *~ 10 | *.swp 11 | /Build 12 | NDependOut 13 | .svn 14 | *.chm -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/ApplicationBootStrapper.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Configuration; 2 | using Fohjin.DDD.Services; 3 | using StructureMap; 4 | 5 | namespace Fohjin.DDD.BankApplication 6 | { 7 | public class ApplicationBootStrapper 8 | { 9 | public void BootStrapTheApplication() 10 | { 11 | DomainDatabaseBootStrapper.BootStrap(); 12 | ReportingDatabaseBootStrapper.BootStrap(); 13 | 14 | ObjectFactory.Initialize(x => 15 | { 16 | x.AddRegistry(); 17 | x.AddRegistry(); 18 | x.AddRegistry(); 19 | x.AddRegistry(); 20 | }); 21 | ObjectFactory.AssertConfigurationIsValid(); 22 | 23 | RegisterCommandHandlersInMessageRouter.BootStrap(); 24 | RegisterEventHandlersInMessageRouter.BootStrap(); 25 | } 26 | 27 | public static void BootStrap() 28 | { 29 | new ApplicationBootStrapper().BootStrapTheApplication(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/ApplicationRegistry.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.BankApplication.Presenters; 2 | using Fohjin.DDD.BankApplication.Views; 3 | using StructureMap.Configuration.DSL; 4 | 5 | namespace Fohjin.DDD.BankApplication 6 | { 7 | public class ApplicationRegistry : Registry 8 | { 9 | public ApplicationRegistry() 10 | { 11 | ForRequestedType().TheDefaultIsConcreteType(); 12 | ForRequestedType().TheDefaultIsConcreteType(); 13 | ForRequestedType().TheDefaultIsConcreteType(); 14 | ForRequestedType().TheDefaultIsConcreteType(); 15 | 16 | ForRequestedType().TheDefaultIsConcreteType(); 17 | ForRequestedType().TheDefaultIsConcreteType(); 18 | ForRequestedType().TheDefaultIsConcreteType(); 19 | ForRequestedType().TheDefaultIsConcreteType(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Presenters/IAccountDetailsPresenter.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Reporting.Dto; 2 | 3 | namespace Fohjin.DDD.BankApplication.Presenters 4 | { 5 | public interface IAccountDetailsPresenter : IPresenter 6 | { 7 | void SetAccount(AccountReport accountReport); 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Presenters/IClientDetailsPresenter.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Reporting.Dto; 2 | 3 | namespace Fohjin.DDD.BankApplication.Presenters 4 | { 5 | public interface IClientDetailsPresenter : IPresenter 6 | { 7 | void SetClient(ClientReport clientReport); 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Presenters/IClientSearchFormPresenter.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.BankApplication.Presenters 2 | { 3 | public interface IClientSearchFormPresenter : IPresenter 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Presenters/IPopupPresenter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.BankApplication.Presenters 4 | { 5 | public interface IPopupPresenter : IPresenter 6 | { 7 | void CatchPossibleException(Action action); 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Presenters/PopupPresenter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.BankApplication.Views; 3 | 4 | namespace Fohjin.DDD.BankApplication.Presenters 5 | { 6 | public class PopupPresenter : Presenter, IPopupPresenter 7 | { 8 | private readonly IPopupView _popupView; 9 | 10 | public PopupPresenter(IPopupView popupView) : base(popupView) 11 | { 12 | _popupView = popupView; 13 | } 14 | 15 | public void CatchPossibleException(System.Action action) 16 | { 17 | try 18 | { 19 | action(); 20 | } 21 | catch (Exception Ex) 22 | { 23 | SetException(Ex); 24 | Display(); 25 | } 26 | } 27 | 28 | private void SetException(Exception exception) 29 | { 30 | _popupView.Exception = exception.GetType().Name; 31 | _popupView.Message = exception.Message; 32 | } 33 | 34 | public void Display() 35 | { 36 | _popupView.ShowDialog(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using Fohjin.DDD.BankApplication.Presenters; 4 | using StructureMap; 5 | 6 | namespace Fohjin.DDD.BankApplication 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | ApplicationBootStrapper.BootStrap(); 17 | 18 | var clientSearchFormPresenter = ObjectFactory.GetInstance(); 19 | 20 | Application.EnableVisualStyles(); 21 | 22 | clientSearchFormPresenter.Display(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.21006.1 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Fohjin.DDD.BankApplication.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Views/ActionDelegate.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Fohjin.DDD.BankApplication.Views 3 | { 4 | public delegate void EventAction(); 5 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Views/ClientSearchForm.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | using Fohjin.DDD.Reporting.Dto; 5 | 6 | namespace Fohjin.DDD.BankApplication.Views 7 | { 8 | public partial class ClientSearchForm : Form, IClientSearchFormView 9 | { 10 | public ClientSearchForm() 11 | { 12 | InitializeComponent(); 13 | tabControl1.Appearance = TabAppearance.FlatButtons; 14 | tabControl1.ItemSize = new Size(0, 1); 15 | tabControl1.SizeMode = TabSizeMode.Fixed; 16 | RegisterCLientEvents(); 17 | } 18 | 19 | public event EventAction OnCreateNewClient; 20 | public event EventAction OnOpenSelectedClient; 21 | 22 | private void RegisterCLientEvents() 23 | { 24 | addANewClientToolStripMenuItem.Click += (s, e) => OnCreateNewClient(); 25 | _clients.Click += (s, e) => OnOpenSelectedClient(); 26 | } 27 | 28 | public IEnumerable Clients 29 | { 30 | get { return (IEnumerable)_clients.DataSource; } 31 | set { _clients.DataSource = value; } 32 | } 33 | 34 | public ClientReport GetSelectedClient() 35 | { 36 | return (ClientReport)_clients.SelectedItem; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Views/IClientSearchFormView.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Fohjin.DDD.Reporting.Dto; 3 | 4 | namespace Fohjin.DDD.BankApplication.Views 5 | { 6 | public interface IClientSearchFormView : IView 7 | { 8 | IEnumerable Clients { get; set; } 9 | ClientReport GetSelectedClient(); 10 | event EventAction OnCreateNewClient; 11 | event EventAction OnOpenSelectedClient; 12 | } 13 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Views/IPopupView.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.BankApplication.Views 2 | { 3 | public interface IPopupView : IView 4 | { 5 | string Exception { set; } 6 | string Message { set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Views/IView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace Fohjin.DDD.BankApplication.Views 5 | { 6 | public interface IView : IDisposable 7 | { 8 | DialogResult ShowDialog(); 9 | void Close(); 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.BankApplication/Views/Popup.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace Fohjin.DDD.BankApplication.Views 4 | { 5 | public partial class Popup : Form, IPopupView 6 | { 7 | public Popup() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | public string Exception 13 | { 14 | set { _exception.Text = value; } 15 | } 16 | 17 | public string Message 18 | { 19 | set { _message.Text = value; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Bus/Direct/IRouteMessages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.Bus.Direct 5 | { 6 | public interface IRouteMessages 7 | { 8 | void Route(object message); 9 | } 10 | 11 | public class MessageRouter : IRouteMessages 12 | { 13 | private readonly IDictionary>> _routes; 14 | 15 | public MessageRouter() 16 | { 17 | _routes = new Dictionary>>(); 18 | } 19 | 20 | public void Register(Action route) where TMessage : class 21 | { 22 | var routingKey = typeof(TMessage); 23 | ICollection> routes; 24 | 25 | if (!_routes.TryGetValue(routingKey, out routes)) 26 | _routes[routingKey] = routes = new LinkedList>(); 27 | 28 | routes.Add(message => route(message as TMessage)); 29 | } 30 | 31 | public void Route(object message) 32 | { 33 | ICollection> routes; 34 | 35 | if (!_routes.TryGetValue(message.GetType(), out routes)) 36 | throw new RouteNotRegisteredException(message.GetType()); 37 | 38 | foreach (var route in routes) 39 | route(message); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Bus/Direct/InMemoryQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.Bus.Direct 5 | { 6 | public interface IQueue 7 | { 8 | void Put(object item); 9 | void Pop(Action popAction); 10 | } 11 | 12 | public class InMemoryQueue : IQueue 13 | { 14 | private readonly Queue _itemQueue; 15 | private readonly Queue> _listenerQueue; 16 | 17 | public InMemoryQueue() 18 | { 19 | _itemQueue = new Queue(32); 20 | _listenerQueue = new Queue>(32); 21 | } 22 | 23 | public void Put(object item) 24 | { 25 | if (_listenerQueue.Count == 0) 26 | { 27 | _itemQueue.Enqueue(item); 28 | return; 29 | } 30 | 31 | var listener = _listenerQueue.Dequeue(); 32 | listener(item); 33 | } 34 | 35 | public void Pop(Action popAction) 36 | { 37 | if (_itemQueue.Count == 0) 38 | { 39 | _listenerQueue.Enqueue(popAction); 40 | return; 41 | } 42 | 43 | var item = _itemQueue.Dequeue(); 44 | popAction(item); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Bus/Direct/RouteNotRegisteredException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Bus.Direct 4 | { 5 | public class RouteNotRegisteredException : Exception 6 | { 7 | public RouteNotRegisteredException(Type messageType) : base(string.Format("No route specified for message '{0}'", messageType.FullName)) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Bus/IBus.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Fohjin.DDD.Bus 4 | { 5 | public interface IBus : IUnitOfWork 6 | { 7 | void Publish(object message); 8 | void Publish(IEnumerable messages); 9 | } 10 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Bus/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Bus 2 | { 3 | public interface IUnitOfWork 4 | { 5 | void Commit(); 6 | void Rollback(); 7 | } 8 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Bus/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Fohjin.DDD.Bus")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Fohjin.DDD.Bus")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3b59e33e-4758-4e02-ba84-233e235f2551")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/AssignNewBankCardCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class AssignNewBankCardCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public AssignNewBankCardCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(AssignNewBankCardCommand assignNewCancelReportStolenBankCardCommand) 17 | { 18 | var client = _repository.GetById(assignNewCancelReportStolenBankCardCommand.Id); 19 | client.AssignNewBankCardForAccount(assignNewCancelReportStolenBankCardCommand.AccountId); 20 | _repository.Add(client); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/CancelBankCardCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class CancelBankCardCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public CancelBankCardCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(CancelBankCardCommand cancelReportStolenBankCardCommand) 17 | { 18 | var client = _repository.GetById(cancelReportStolenBankCardCommand.Id); 19 | var bankCard = client.GetBankCard(cancelReportStolenBankCardCommand.BankCardId); 20 | bankCard.ClientCancelsBankCard(); 21 | _repository.Add(client); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/ChangeAccountNameCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Account; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class ChangeAccountNameCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public ChangeAccountNameCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(ChangeAccountNameCommand compensatingCommand) 17 | { 18 | var activeAccount = _repository.GetById(compensatingCommand.Id); 19 | 20 | activeAccount.ChangeAccountName(new AccountName(compensatingCommand.AccountName)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/ChangeClientNameCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class ChangeClientNameCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public ChangeClientNameCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(ChangeClientNameCommand compensatingCommand) 17 | { 18 | var client = _repository.GetById(compensatingCommand.Id); 19 | 20 | client.UpdateClientName(new ClientName(compensatingCommand.ClientName)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/ChangeClientPhoneNumberCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class ChangeClientPhoneNumberCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public ChangeClientPhoneNumberCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(ChangeClientPhoneNumberCommand compensatingCommand) 17 | { 18 | var client = _repository.GetById(compensatingCommand.Id); 19 | 20 | client.UpdatePhoneNumber(new PhoneNumber(compensatingCommand.PhoneNumber)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/ClientIsMovingCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class ClientIsMovingCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public ClientIsMovingCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(ClientIsMovingCommand compensatingCommand) 17 | { 18 | var client = _repository.GetById(compensatingCommand.Id); 19 | 20 | client.ClientMoved(new Address(compensatingCommand.Street, compensatingCommand.StreetNumber, compensatingCommand.PostalCode, compensatingCommand.City)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/CloseAnAccountCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Account; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class CloseAccountCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public CloseAccountCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(CloseAccountCommand compensatingCommand) 17 | { 18 | var activeAccount = _repository.GetById(compensatingCommand.Id); 19 | 20 | var closedAccount = activeAccount.Close(); 21 | 22 | _repository.Add(closedAccount); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/CreateClientCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class CreateClientCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public CreateClientCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(CreateClientCommand compensatingCommand) 17 | { 18 | var client = Client.CreateNew(new ClientName(compensatingCommand.ClientName), new Address(compensatingCommand.Street, compensatingCommand.StreetNumber, compensatingCommand.PostalCode, compensatingCommand.City), new PhoneNumber(compensatingCommand.PhoneNumber)); 19 | 20 | _repository.Add(client); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/DepositeCashCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Account; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class DepositeCashCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public DepositeCashCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(DepositeCashCommand compensatingCommand) 17 | { 18 | var activeAccount = _repository.GetById(compensatingCommand.Id); 19 | 20 | activeAccount.Deposite(new Amount(compensatingCommand.Amount)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/ICommandHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.CommandHandlers 2 | { 3 | public interface ICommandHandler where TCommand : class 4 | { 5 | void Execute(TCommand command); 6 | } 7 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/MoneyTransferFailedCompensatingCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Account; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class MoneyTransferFailedCompensatingCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public MoneyTransferFailedCompensatingCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(MoneyTransferFailedCompensatingCommand compensatingCommand) 17 | { 18 | var activeAccount = _repository.GetById(compensatingCommand.Id); 19 | 20 | activeAccount.PreviousTransferFailed(new AccountNumber(compensatingCommand.AccountNumber), new Amount(compensatingCommand.Amount)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/OpenNewAccountForClientCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class OpenNewAccountForClientCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public OpenNewAccountForClientCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(OpenNewAccountForClientCommand compensatingCommand) 17 | { 18 | var client = _repository.GetById(compensatingCommand.Id); 19 | var activeAccount = client.CreateNewAccount(compensatingCommand.AccountName); 20 | 21 | _repository.Add(activeAccount); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/ReceiveMoneyTransferCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Account; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class ReceiveMoneyTransferCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public ReceiveMoneyTransferCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(ReceiveMoneyTransferCommand compensatingCommand) 17 | { 18 | var activeAccount = _repository.GetById(compensatingCommand.Id); 19 | 20 | activeAccount.ReceiveTransferFrom(new AccountNumber(compensatingCommand.AccountNumber), new Amount(compensatingCommand.Amount)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/ReportStolenBankCardCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Client; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class ReportStolenBankCardCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public ReportStolenBankCardCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(ReportStolenBankCardCommand cancelReportStolenBankCardCommand) 17 | { 18 | var client = _repository.GetById(cancelReportStolenBankCardCommand.Id); 19 | var bankCard = client.GetBankCard(cancelReportStolenBankCardCommand.BankCardId); 20 | bankCard.BankCardIsReportedStolen(); 21 | _repository.Add(client); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/SendMoneyTransferCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Account; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class SendMoneyTransferCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public SendMoneyTransferCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(SendMoneyTransferCommand compensatingCommand) 17 | { 18 | var activeAccount = _repository.GetById(compensatingCommand.Id); 19 | 20 | activeAccount.SendTransferTo(new AccountNumber(compensatingCommand.AccountNumber), new Amount(compensatingCommand.Amount)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/TransactionHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore; 3 | 4 | namespace Fohjin.DDD.CommandHandlers 5 | { 6 | public class TransactionHandler 7 | where TCommandHandler : ICommandHandler 8 | where TCommand : class 9 | { 10 | private readonly IUnitOfWork _unitOfWork; 11 | 12 | public TransactionHandler(IUnitOfWork unitOfWork) 13 | { 14 | _unitOfWork = unitOfWork; 15 | } 16 | 17 | public void Execute(TCommand command, TCommandHandler commandHandler) 18 | { 19 | try 20 | { 21 | commandHandler.Execute(command); 22 | _unitOfWork.Commit(); 23 | } 24 | catch (Exception Ex) 25 | { 26 | _unitOfWork.Rollback(); 27 | throw; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.CommandHandlers/WithdrawlCashCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Commands; 2 | using Fohjin.DDD.Domain.Account; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Fohjin.DDD.CommandHandlers 6 | { 7 | public class WithdrawlCashCommandHandler : ICommandHandler 8 | { 9 | private readonly IDomainRepository _repository; 10 | 11 | public WithdrawlCashCommandHandler(IDomainRepository repository) 12 | { 13 | _repository = repository; 14 | } 15 | 16 | public void Execute(WithdrawlCashCommand compensatingCommand) 17 | { 18 | var activeAccount = _repository.GetById(compensatingCommand.Id); 19 | 20 | activeAccount.Withdrawl(new Amount(compensatingCommand.Amount)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/AssignNewBankCardCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class AssignNewBankCardCommand : Command 7 | { 8 | public Guid AccountId { get; set; } 9 | 10 | public AssignNewBankCardCommand(Guid id, Guid accountId) : base(id) 11 | { 12 | AccountId = accountId; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/CancelBankCardCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class CancelBankCardCommand : Command 7 | { 8 | public Guid BankCardId { get; private set; } 9 | 10 | public CancelBankCardCommand(Guid id, Guid bankCardId) : base(id) 11 | { 12 | BankCardId = bankCardId; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/ChangeAccountNameCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class ChangeAccountNameCommand : Command 7 | { 8 | public string AccountName { get; private set; } 9 | 10 | public ChangeAccountNameCommand(Guid id, string accountName) : base(id) 11 | { 12 | AccountName = accountName; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/ChangeClientNameCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class ChangeClientNameCommand : Command 7 | { 8 | public string ClientName { get; private set; } 9 | 10 | public ChangeClientNameCommand(Guid id, string clientName) : base(id) 11 | { 12 | ClientName = clientName; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/ChangeClientPhoneNumberCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class ChangeClientPhoneNumberCommand : Command 7 | { 8 | public string PhoneNumber { get; private set; } 9 | 10 | public ChangeClientPhoneNumberCommand(Guid id, string phoneNumber) : base(id) 11 | { 12 | PhoneNumber = phoneNumber; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/ClientIsMovingCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class ClientIsMovingCommand : Command 7 | { 8 | public string Street { get; private set; } 9 | public string StreetNumber { get; private set; } 10 | public string PostalCode { get; private set; } 11 | public string City { get; private set; } 12 | 13 | public ClientIsMovingCommand(Guid id, string street, string streetNumber, string postalCode, string city) : base(id) 14 | { 15 | Street = street; 16 | StreetNumber = streetNumber; 17 | PostalCode = postalCode; 18 | City = city; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/CloseAccountCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class CloseAccountCommand : Command 7 | { 8 | public CloseAccountCommand(Guid id) : base(id) { } 9 | } 10 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/Command.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class Command : ICommand 7 | { 8 | public Guid Id { get; private set; } 9 | 10 | public Command(Guid id) 11 | { 12 | Id = id; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/CreateClientCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class CreateClientCommand : Command 7 | { 8 | public string ClientName { get; private set; } 9 | public string Street { get; private set; } 10 | public string StreetNumber { get; private set; } 11 | public string PostalCode { get; private set; } 12 | public string City { get; private set; } 13 | public string PhoneNumber { get; private set; } 14 | 15 | public CreateClientCommand(Guid id, string clientName, string street, string streetNumber, string postalCode, string city, string phoneNumber) : base(id) 16 | { 17 | ClientName = clientName; 18 | Street = street; 19 | StreetNumber = streetNumber; 20 | PostalCode = postalCode; 21 | City = city; 22 | PhoneNumber = phoneNumber; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/DepositeCashCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class DepositeCashCommand : Command 7 | { 8 | public decimal Amount { get; private set; } 9 | 10 | public DepositeCashCommand(Guid id, decimal amount) : base(id) 11 | { 12 | Amount = amount; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/ICommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | public interface ICommand 6 | { 7 | Guid Id { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/MoneyTransferFailedCompensatingCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class MoneyTransferFailedCompensatingCommand : Command 7 | { 8 | public decimal Amount { get; private set; } 9 | public string AccountNumber { get; private set; } 10 | 11 | public MoneyTransferFailedCompensatingCommand(Guid id, decimal amount, string targetAccountNumber) : base(id) 12 | { 13 | Amount = amount; 14 | AccountNumber = targetAccountNumber; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/OpenNewAccountForClientCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class OpenNewAccountForClientCommand : Command 7 | { 8 | public string AccountName { get; private set; } 9 | 10 | public OpenNewAccountForClientCommand(Guid id, string accountName) : base(id) 11 | { 12 | AccountName = accountName; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/ReceiveMoneyTransferCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class ReceiveMoneyTransferCommand : Command 7 | { 8 | public decimal Amount { get; private set; } 9 | public string AccountNumber { get; private set; } 10 | 11 | public ReceiveMoneyTransferCommand(Guid id, decimal amount, string accountNumber) : base(id) 12 | { 13 | Amount = amount; 14 | AccountNumber = accountNumber; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/ReportStolenBankCardCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class ReportStolenBankCardCommand : Command 7 | { 8 | public Guid BankCardId { get; private set; } 9 | 10 | public ReportStolenBankCardCommand(Guid id, Guid bankCardId) : base(id) 11 | { 12 | BankCardId = bankCardId; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/SendMoneyTransferCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class SendMoneyTransferCommand : Command 7 | { 8 | public decimal Amount { get; private set; } 9 | public string AccountNumber { get; private set; } 10 | 11 | public SendMoneyTransferCommand(Guid id, decimal amount, string accountNumber) : base(id) 12 | { 13 | Amount = amount; 14 | AccountNumber = accountNumber; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Commands/WithdrawlCashCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Commands 4 | { 5 | [Serializable] 6 | public class WithdrawlCashCommand : Command 7 | { 8 | public decimal Amount { get; private set; } 9 | 10 | public WithdrawlCashCommand(Guid id, decimal amount) : base(id) 11 | { 12 | Amount = amount; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Configuration/ReportingRegistry.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Reporting; 2 | using Fohjin.DDD.Reporting.Infrastructure; 3 | using StructureMap.Configuration.DSL; 4 | 5 | namespace Fohjin.DDD.Configuration 6 | { 7 | public class ReportingRegistry : Registry 8 | { 9 | private const string sqLiteConnectionString = "Data Source=reportingDataBase.db3"; 10 | 11 | public ReportingRegistry() 12 | { 13 | ForRequestedType().TheDefault.Is.OfConcreteType(); 14 | ForRequestedType().TheDefault.Is.OfConcreteType(); 15 | ForRequestedType().TheDefault.Is.OfConcreteType(); 16 | ForRequestedType().TheDefault.Is.OfConcreteType(); 17 | ForRequestedType().TheDefault.Is.OfConcreteType(); 18 | 19 | ForRequestedType().TheDefault.Is.OfConcreteType() 20 | .WithCtorArg("sqLiteConnectionString").EqualTo(sqLiteConnectionString); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/AccountBalanceNotZeroException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Account 4 | { 5 | public class AccountBalanceNotZeroException : Exception 6 | { 7 | public AccountBalanceNotZeroException(string message) : base(message) { } 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/AccountBalanceToLowException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Account 4 | { 5 | public class AccountBalanceToLowException : Exception 6 | { 7 | public AccountBalanceToLowException(string message) : base(message) { } 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/AccountName.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Account 2 | { 3 | public class AccountName 4 | { 5 | public string Name { get; private set; } 6 | 7 | public AccountName(string name) 8 | { 9 | Name = name; 10 | } 11 | 12 | public override string ToString() 13 | { 14 | return Name; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/AccountNumber.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Account 2 | { 3 | public class AccountNumber 4 | { 5 | public string Number { get; private set; } 6 | 7 | public AccountNumber(string number) 8 | { 9 | Number = number; 10 | } 11 | 12 | public override string ToString() 13 | { 14 | return Number; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/Amount.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Account 2 | { 3 | public class Amount 4 | { 5 | private readonly decimal _decimalAmount; 6 | 7 | public Amount(decimal decimalAmount) 8 | { 9 | _decimalAmount = decimalAmount; 10 | } 11 | 12 | public Amount Substract(Amount amount) 13 | { 14 | var newDecimalAmount = _decimalAmount - amount._decimalAmount; 15 | return new Amount(newDecimalAmount); 16 | } 17 | 18 | public Amount Add(Amount amount) 19 | { 20 | var newDecimalAmount = _decimalAmount + amount._decimalAmount; 21 | return new Amount(newDecimalAmount); 22 | } 23 | 24 | public bool IsNegative() 25 | { 26 | return _decimalAmount < 0; 27 | } 28 | 29 | public static implicit operator decimal(Amount amount) 30 | { 31 | return amount._decimalAmount; 32 | } 33 | 34 | public static implicit operator Amount(decimal decimalAmount) 35 | { 36 | return new Amount(decimalAmount); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/Balance.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Account 2 | { 3 | public class Balance 4 | { 5 | private readonly Amount _amount; 6 | 7 | public Balance() 8 | { 9 | _amount = new Amount(0); 10 | } 11 | 12 | private Balance(decimal decimalAmount) 13 | { 14 | _amount = new Amount(decimalAmount); 15 | } 16 | 17 | public Balance Withdrawl(Amount amount) 18 | { 19 | return new Balance(_amount.Substract(amount)); 20 | } 21 | 22 | public Balance Deposite(Amount amount) 23 | { 24 | return new Balance(_amount.Add(amount)); 25 | } 26 | 27 | public bool WithdrawlWillResultInNegativeBalance(Amount amount) 28 | { 29 | return new Amount(_amount).Substract(amount).IsNegative(); 30 | } 31 | 32 | public static implicit operator decimal(Balance balance) 33 | { 34 | return balance._amount; 35 | } 36 | 37 | public static implicit operator Balance(decimal decimalAmount) 38 | { 39 | return new Balance(decimalAmount); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/ClosedAccountException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Account 4 | { 5 | public class ClosedAccountException : Exception 6 | { 7 | public ClosedAccountException(string message) : base(message) { } 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/Ledger.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Account 2 | { 3 | public abstract class Ledger 4 | { 5 | public Amount Amount { get; private set; } 6 | public AccountNumber Account { get; private set; } 7 | 8 | protected Ledger(Amount amount, AccountNumber account) 9 | { 10 | Amount = amount; 11 | Account = account; 12 | } 13 | 14 | public override string ToString() 15 | { 16 | return string.Format("{0} - {1} - {2}", GetType().Name, Account.Number, (decimal)Amount); 17 | } 18 | } 19 | 20 | public class CreditMutation : Ledger 21 | { 22 | public CreditMutation(Amount amount, AccountNumber account) : base(amount, account) { } 23 | } 24 | 25 | public class DebitMutation : Ledger 26 | { 27 | public DebitMutation(Amount amount, AccountNumber account) : base(amount, account) { } 28 | } 29 | 30 | public class CreditTransfer : Ledger 31 | { 32 | public CreditTransfer(Amount amount, AccountNumber account) : base(amount, account) { } 33 | } 34 | 35 | public class DebitTransfer : Ledger 36 | { 37 | public DebitTransfer(Amount amount, AccountNumber account) : base(amount, account) { } 38 | } 39 | 40 | public class DebitTransferFailed : Ledger 41 | { 42 | public DebitTransferFailed(Amount amount, AccountNumber account) : base(amount, account) { } 43 | } 44 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Account/NonExitsingAccountException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Account 4 | { 5 | public class NonExitsingAccountException : Exception 6 | { 7 | public NonExitsingAccountException(string message) : base(message) {} 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/Address.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Client 2 | { 3 | public class Address 4 | { 5 | public string Street { get; private set; } 6 | public string StreetNumber { get; private set; } 7 | public string PostalCode { get; private set; } 8 | public string City { get; private set; } 9 | 10 | public Address(string street, string streetNumber, string postalCode, string city) 11 | { 12 | Street = street; 13 | StreetNumber = streetNumber; 14 | PostalCode = postalCode; 15 | City = city; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/BankCardIsDisabledException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Client 4 | { 5 | public class BankCardIsDisabledException : Exception 6 | { 7 | public BankCardIsDisabledException(string message) : base(message) { } 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/ClientName.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Client 2 | { 3 | public class ClientName 4 | { 5 | public string Name { get; private set; } 6 | 7 | public ClientName(string name) 8 | { 9 | Name = name; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/IBankCard.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Client 2 | { 3 | public interface IBankCard 4 | { 5 | void BankCardIsReportedStolen(); 6 | void ClientCancelsBankCard(); 7 | } 8 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/NonExistingAccountException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Client 4 | { 5 | public class NonExistingAccountException : Exception 6 | { 7 | public NonExistingAccountException(string message) : base(message) { } 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/NonExistingBankCardException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Client 4 | { 5 | public class NonExistingBankCardException : Exception 6 | { 7 | public NonExistingBankCardException(string message) : base(message) {} 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/NonExistingClientException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Domain.Client 4 | { 5 | public class NonExistingClientException : Exception 6 | { 7 | public NonExistingClientException(string message) : base(message) {} 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Client/PhoneNumber.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Domain.Client 2 | { 3 | public class PhoneNumber 4 | { 5 | public string Number { get; private set; } 6 | 7 | public PhoneNumber(string number) 8 | { 9 | Number = number; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Mementos/ActiveAccountMemento.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.Domain.Account; 4 | using Fohjin.DDD.EventStore.Storage.Memento; 5 | 6 | namespace Fohjin.DDD.Domain.Mementos 7 | { 8 | [Serializable] 9 | public class ActiveAccountMemento : IMemento 10 | { 11 | internal Guid Id { get; private set; } 12 | internal int Version { get; private set; } 13 | internal Guid ClientId { get; private set; } 14 | internal string AccountName { get; private set; } 15 | internal string AccountNumber { get; set; } 16 | internal decimal Balance { get; private set; } 17 | internal bool Closed { get; private set; } 18 | internal List> Ledgers { get; private set; } 19 | 20 | public ActiveAccountMemento(Guid id, int version, Guid clientId, string accountName, string accountNumber, decimal balance, List ledgers, bool closed) 21 | { 22 | Id = id; 23 | Version = version; 24 | ClientId = clientId; 25 | AccountName = accountName; 26 | AccountNumber = accountNumber; 27 | Balance = balance; 28 | Closed = closed; 29 | Ledgers = new List>(); 30 | ledgers.ForEach(x => Ledgers.Add(new KeyValuePair(x.GetType().Name, string.Format("{0}|{1}", ((decimal)x.Amount), x.Account.Number)))); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Mementos/BankCardMemento.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore.Storage.Memento; 3 | 4 | namespace Fohjin.DDD.Domain.Mementos 5 | { 6 | [Serializable] 7 | public class BankCardMemento : IMemento 8 | { 9 | internal Guid Id { get; private set; } 10 | internal Guid AccountId { get; private set; } 11 | internal bool Disabled { get; private set; } 12 | 13 | public BankCardMemento(Guid id, Guid accountId, bool disabled) 14 | { 15 | Id = id; 16 | AccountId = accountId; 17 | Disabled = disabled; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Mementos/ClientMemento.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.EventStore.Storage.Memento; 4 | 5 | namespace Fohjin.DDD.Domain.Mementos 6 | { 7 | [Serializable] 8 | public class ClientMemento : IMemento 9 | { 10 | internal Guid Id { get; private set; } 11 | internal int Version { get; private set; } 12 | internal string ClientName { get; private set; } 13 | internal string Street { get; private set; } 14 | internal string StreetNumber { get; private set; } 15 | internal string PostalCode { get; private set; } 16 | internal string City { get; private set; } 17 | internal string PhoneNumber { get; private set; } 18 | internal List Accounts { get; private set; } 19 | internal List BankCardMementos { get; private set; } 20 | 21 | public ClientMemento(Guid id, int version, string clientName, string street, string streetNumber, string postalCode, string city, string phoneNumber, List accounts, List bankCardMementos) 22 | { 23 | Id = id; 24 | Version = version; 25 | ClientName = clientName; 26 | Street = street; 27 | StreetNumber = streetNumber; 28 | PostalCode = postalCode; 29 | City = city; 30 | PhoneNumber = phoneNumber; 31 | Accounts = accounts; 32 | BankCardMementos = bankCardMementos; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Domain/Mementos/ClosedAccountMemento.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.Domain.Account; 4 | using Fohjin.DDD.EventStore.Storage.Memento; 5 | 6 | namespace Fohjin.DDD.Domain.Mementos 7 | { 8 | [Serializable] 9 | public class ClosedAccountMemento : IMemento 10 | { 11 | internal Guid Id { get; private set; } 12 | internal int Version { get; private set; } 13 | internal Guid OriginalAccountId { get; private set; } 14 | internal Guid ClientId { get; private set; } 15 | internal string AccountName { get; private set; } 16 | internal string AccountNumber { get; private set; } 17 | internal List> Ledgers { get; private set; } 18 | 19 | public ClosedAccountMemento(Guid id, int version, Guid originalAccountId, Guid clientId, string accountName, string accountNumber, List ledgers) 20 | { 21 | Id = id; 22 | Version = version; 23 | OriginalAccountId = originalAccountId; 24 | ClientId = clientId; 25 | AccountName = accountName; 26 | AccountNumber = accountNumber; 27 | Ledgers = new List>(); 28 | ledgers.ForEach(x => Ledgers.Add(new KeyValuePair(x.GetType().Name, string.Format("{0}|{1}", ((decimal)x.Amount), x.Account.Number)))); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/AccountClosedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class AccountClosedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public AccountClosedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(AccountClosedEvent theEvent) 17 | { 18 | _reportingRepository.Delete(new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Delete(new { Id = theEvent.AggregateId }); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/AccountNameChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class AccountNameChangedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public AccountNameChangedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(AccountNameChangedEvent theEvent) 17 | { 18 | _reportingRepository.Update(new { theEvent.AccountName }, new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Update(new { theEvent.AccountName }, new { Id = theEvent.AggregateId }); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/AccountOpenedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class AccountOpenedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public AccountOpenedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(AccountOpenedEvent theEvent) 17 | { 18 | var account = new AccountReport(theEvent.AccountId, theEvent.ClientId, theEvent.AccountName, theEvent.AccountNumber); 19 | var accountDetails = new AccountDetailsReport(theEvent.AccountId, theEvent.ClientId, theEvent.AccountName, 0.0M, theEvent.AccountNumber); 20 | _reportingRepository.Save(account); 21 | _reportingRepository.Save(accountDetails); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/AccountToClientAssignedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Client; 2 | 3 | namespace Fohjin.DDD.EventHandlers 4 | { 5 | public class AccountToClientAssignedEventHandler : IEventHandler 6 | { 7 | public void Execute(AccountToClientAssignedEvent theEvent) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/BankCardWasCanceledByCLientEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.Events.Client; 3 | using Fohjin.DDD.Reporting; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class BankCardWasCanceledByCLientEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public BankCardWasCanceledByCLientEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(BankCardWasCanceledByCLientEvent theEvent) 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/BankCardWasReportedStolenEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.Events.Client; 3 | using Fohjin.DDD.Reporting; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class BankCardWasReportedStolenEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public BankCardWasReportedStolenEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(BankCardWasReportedStolenEvent theEvent) 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/CashDepositeEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class CashDepositeEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public CashDepositeEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(CashDepositedEvent theEvent) 17 | { 18 | _reportingRepository.Update(new {theEvent.Balance }, new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Save(new LedgerReport(theEvent.Id, theEvent.AggregateId, "Deposite", theEvent.Amount)); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/CashWithdrawnEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class CashWithdrawnEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public CashWithdrawnEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(CashWithdrawnEvent theEvent) 17 | { 18 | _reportingRepository.Update(new {theEvent.Balance }, new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Save(new LedgerReport(theEvent.Id, theEvent.AggregateId, "Withdrawl", theEvent.Amount)); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/ClientCreatedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Client; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class ClientCreatedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public ClientCreatedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(ClientCreatedEvent theEvent) 17 | { 18 | var client = new ClientReport(theEvent.ClientId, theEvent.ClientName); 19 | var clientDetails = new ClientDetailsReport(theEvent.ClientId, theEvent.ClientName, theEvent.Street, theEvent.StreetNumber, theEvent.PostalCode, theEvent.City, theEvent.PhoneNumber); 20 | _reportingRepository.Save(client); 21 | _reportingRepository.Save(clientDetails); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/ClientMovedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Client; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class ClientMovedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public ClientMovedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(ClientMovedEvent theEvent) 17 | { 18 | _reportingRepository.Update(new { theEvent.Street, theEvent.StreetNumber, theEvent.PostalCode, theEvent.City }, new { Id = theEvent.AggregateId }); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/ClientNameChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Client; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class ClientNameChangedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public ClientNameChangedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(ClientNameChangedEvent theEvent) 17 | { 18 | _reportingRepository.Update(new { Name = theEvent.ClientName }, new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Update(new { theEvent.ClientName }, new { Id = theEvent.AggregateId }); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/ClientPhoneNumberChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Client; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class ClientPhoneNumberChangedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public ClientPhoneNumberChangedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(ClientPhoneNumberChangedEvent theEvent) 17 | { 18 | _reportingRepository.Update(new { theEvent.PhoneNumber }, new { Id = theEvent.AggregateId }); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/IEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.EventHandlers 2 | { 3 | public interface IEventHandler where TEvent : class 4 | { 5 | void Execute(TEvent theEvent); 6 | } 7 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/MoneyTransferFailedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class MoneyTransferFailedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public MoneyTransferFailedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(MoneyTransferFailedEvent theEvent) 17 | { 18 | _reportingRepository.Update(new { theEvent.Balance }, new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Save(new LedgerReport(theEvent.Id, theEvent.AggregateId, string.Format("Transfer to {0} failed", theEvent.TargetAccount), theEvent.Amount)); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/MoneyTransferReceivedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class MoneyTransferReceivedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public MoneyTransferReceivedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(MoneyTransferReceivedEvent theEvent) 17 | { 18 | _reportingRepository.Update(new {theEvent.Balance }, new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Save(new LedgerReport(theEvent.Id, theEvent.AggregateId, string.Format("Transfer from {0}", theEvent.SourceAccount), theEvent.Amount)); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/MoneyTransferSendEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class MoneyTransferSendEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public MoneyTransferSendEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(MoneyTransferSendEvent theEvent) 17 | { 18 | _reportingRepository.Update(new {theEvent.Balance }, new { Id = theEvent.AggregateId }); 19 | _reportingRepository.Save(new LedgerReport(theEvent.Id, theEvent.AggregateId, string.Format("Transfer to {0}", theEvent.TargetAccount), theEvent.Amount)); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/NewBankCardForAccountAssignedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.Events.Client; 3 | using Fohjin.DDD.Reporting; 4 | 5 | namespace Fohjin.DDD.EventHandlers 6 | { 7 | public class NewBankCardForAccountAssignedEventHandler : IEventHandler 8 | { 9 | private readonly IReportingRepository _reportingRepository; 10 | 11 | public NewBankCardForAccountAssignedEventHandler(IReportingRepository reportingRepository) 12 | { 13 | _reportingRepository = reportingRepository; 14 | } 15 | 16 | public void Execute(NewBankCardForAccountAsignedEvent theEvent) 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventHandlers/SendMoneyTransferFurtherEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Events.Account; 2 | using Fohjin.DDD.Services; 3 | 4 | namespace Fohjin.DDD.EventHandlers 5 | { 6 | public class SendMoneyTransferFurtherEventHandler : IEventHandler 7 | { 8 | private readonly ISendMoneyTransfer _sendMoneyTransfer; 9 | 10 | public SendMoneyTransferFurtherEventHandler(ISendMoneyTransfer sendMoneyTransfer) 11 | { 12 | _sendMoneyTransfer = sendMoneyTransfer; 13 | } 14 | 15 | public void Execute(MoneyTransferSendEvent theEvent) 16 | { 17 | _sendMoneyTransfer.Send(new MoneyTransfer(theEvent.SourceAccount, theEvent.TargetAccount, theEvent.Amount)); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore.SQLite/ConcurrencyViolationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.EventStore.SQLite 4 | { 5 | public class ConcurrencyViolationException : Exception { } 6 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Aggregate/BaseEntityExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Fohjin.DDD.EventStore.Aggregate 6 | { 7 | public static class TryGetByIdExtension 8 | { 9 | public static bool TryGetValueById(this IEnumerable list, Guid Id, out IEntityEventProvider baseEntity) 10 | where TEventProvider : IEntityEventProvider 11 | where TDomainEvent : IDomainEvent 12 | { 13 | baseEntity = list.Where(x => x.Id == Id).FirstOrDefault(); 14 | return baseEntity != null; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Aggregate/EntityList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Fohjin.DDD.EventStore.Aggregate 4 | { 5 | public class EntityList : List 6 | where TEntity : IEntityEventProvider 7 | where TDomainEvent : IDomainEvent 8 | { 9 | private readonly IRegisterChildEntities _aggregateRoot; 10 | 11 | public EntityList(IRegisterChildEntities aggregateRoot) 12 | { 13 | _aggregateRoot = aggregateRoot; 14 | } 15 | 16 | public EntityList(IRegisterChildEntities aggregateRoot, int capacity) 17 | : base(capacity) 18 | { 19 | _aggregateRoot = aggregateRoot; 20 | } 21 | 22 | public EntityList(IRegisterChildEntities aggregateRoot, IEnumerable collection) 23 | : base(collection) 24 | { 25 | _aggregateRoot = aggregateRoot; 26 | } 27 | 28 | public new void Add(TEntity entity) 29 | { 30 | _aggregateRoot.RegisterChildEventProvider(entity); 31 | base.Add(entity); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Aggregate/UnregisteredDomainEventException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.EventStore.Aggregate 4 | { 5 | public class UnregisteredDomainEventException : Exception 6 | { 7 | public UnregisteredDomainEventException(string message) : base(message) {} 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/IDomainEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.EventStore 4 | { 5 | public interface IDomainEvent 6 | { 7 | Guid Id { get; } 8 | Guid AggregateId { get; set; } 9 | int Version { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/IDomainRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore.Storage.Memento; 3 | 4 | namespace Fohjin.DDD.EventStore 5 | { 6 | public interface IDomainRepository where TDomainEvent : IDomainEvent 7 | { 8 | TAggregate GetById(Guid id) 9 | where TAggregate : class, IOrginator, IEventProvider, new(); 10 | 11 | void Add(TAggregate aggregateRoot) 12 | where TAggregate : class, IOrginator, IEventProvider, new(); 13 | } 14 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/IEntityEventProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.EventStore 5 | { 6 | public interface IEntityEventProvider where TDomainEvent : IDomainEvent 7 | { 8 | void Clear(); 9 | void LoadFromHistory(IEnumerable domainEvents); 10 | void HookUpVersionProvider(Func versionProvider); 11 | IEnumerable GetChanges(); 12 | Guid Id { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/IEventProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.EventStore 5 | { 6 | public interface IEventProvider where TDomainEvent : IDomainEvent 7 | { 8 | void Clear(); 9 | void LoadFromHistory(IEnumerable domainEvents); 10 | void UpdateVersion(int version); 11 | Guid Id { get; } 12 | int Version { get; } 13 | IEnumerable GetChanges(); 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/IRegisterChildEntities.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.EventStore 2 | { 3 | public interface IRegisterChildEntities where TDomainEvent : IDomainEvent 4 | { 5 | void RegisterChildEventProvider(IEntityEventProvider entityEventProvider); 6 | } 7 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/ITransactional.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.EventStore 2 | { 3 | public interface ITransactional 4 | { 5 | void BeginTransaction(); 6 | void Commit(); 7 | void Rollback(); 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Fohjin.DDD.EventStore 3 | { 4 | public interface IUnitOfWork 5 | { 6 | void Commit(); 7 | void Rollback(); 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/IDomainEventStorage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.EventStore.Storage 5 | { 6 | public interface IDomainEventStorage : ISnapShotStorage, ITransactional where TDomainEvent : IDomainEvent 7 | { 8 | IEnumerable GetAllEvents(Guid eventProviderId); 9 | IEnumerable GetEventsSinceLastSnapShot(Guid eventProviderId); 10 | int GetEventCountSinceLastSnapShot(Guid eventProviderId); 11 | void Save(IEventProvider eventProvider); 12 | } 13 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/IEventStoreUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore.Storage.Memento; 3 | 4 | namespace Fohjin.DDD.EventStore.Storage 5 | { 6 | public interface IEventStoreUnitOfWork : IUnitOfWork where TDomainEvent : IDomainEvent 7 | { 8 | TAggregate GetById(Guid id) where TAggregate : class, IOrginator, IEventProvider, new(); 9 | void Add(TAggregate aggregateRoot) where TAggregate : class, IOrginator, IEventProvider, new(); 10 | void RegisterForTracking(TAggregate aggregateRoot) where TAggregate : class, IOrginator, IEventProvider, new(); 11 | } 12 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/IIdentityMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore.Storage.Memento; 3 | 4 | namespace Fohjin.DDD.EventStore.Storage 5 | { 6 | public interface IIdentityMap where TDomainEvent : IDomainEvent 7 | { 8 | TAggregate GetById(Guid id) where TAggregate : class, IOrginator, IEventProvider, new(); 9 | void Add(TAggregate aggregateRoot) where TAggregate : class, IOrginator, IEventProvider, new(); 10 | void Remove(Type aggregateRootType, Guid aggregateRootId); 11 | } 12 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/ISnapShot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore.Storage.Memento; 3 | 4 | namespace Fohjin.DDD.EventStore.Storage 5 | { 6 | public interface ISnapShot 7 | { 8 | IMemento Memento { get; } 9 | Guid EventProviderId { get; } 10 | int Version { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/ISnapShotStorage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.EventStore.Storage 4 | { 5 | public interface ISnapShotStorage where TDomainEvent : IDomainEvent 6 | { 7 | ISnapShot GetSnapShot(Guid entityId); 8 | void SaveShapShot(IEventProvider entity); 9 | } 10 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/Memento/IMomento.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.EventStore.Storage.Memento 2 | { 3 | public interface IMemento 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/Memento/IOrginator.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.EventStore.Storage.Memento 2 | { 3 | public interface IOrginator 4 | { 5 | IMemento CreateMemento(); 6 | void SetMemento(IMemento memento); 7 | } 8 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.EventStore/Storage/SnapShot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore.Storage.Memento; 3 | 4 | namespace Fohjin.DDD.EventStore.Storage 5 | { 6 | [Serializable] 7 | public class SnapShot : ISnapShot 8 | { 9 | public SnapShot(Guid eventProviderId, int version, IMemento memento) 10 | { 11 | EventProviderId = eventProviderId; 12 | Version = version; 13 | Memento = memento; 14 | } 15 | 16 | public Guid EventProviderId { get; private set; } 17 | public int Version { get; private set; } 18 | public IMemento Memento { get; private set; } 19 | } 20 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/AccountClosedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class AccountClosedEvent : DomainEvent 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/AccountNameChangedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class AccountNameChangedEvent : DomainEvent 7 | { 8 | public string AccountName { get; private set; } 9 | 10 | public AccountNameChangedEvent(string accountName) 11 | { 12 | AccountName = accountName; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/AccountOpenedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class AccountOpenedEvent : DomainEvent 7 | { 8 | public Guid AccountId { get; private set; } 9 | public Guid ClientId { get; private set; } 10 | public string AccountName { get; private set; } 11 | public string AccountNumber { get; private set; } 12 | 13 | public AccountOpenedEvent(Guid accountId, Guid clientId, string accountName, string accountNumber) 14 | { 15 | AccountId = accountId; 16 | ClientId = clientId; 17 | AccountName = accountName; 18 | AccountNumber = accountNumber; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/CashDepositedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class CashDepositedEvent : DomainEvent 7 | { 8 | public decimal Balance { get; private set; } 9 | public decimal Amount { get; private set; } 10 | 11 | public CashDepositedEvent(decimal balance, decimal amount) 12 | { 13 | Balance = balance; 14 | Amount = amount; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/CashWithdrawnEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class CashWithdrawnEvent : DomainEvent 7 | { 8 | public decimal Balance { get; private set; } 9 | public decimal Amount { get; private set; } 10 | 11 | public CashWithdrawnEvent(decimal balance, decimal amount) 12 | { 13 | Balance = balance; 14 | Amount = amount; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/ClosedAccountCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.Events.Account 5 | { 6 | [Serializable] 7 | public class ClosedAccountCreatedEvent : DomainEvent 8 | { 9 | public Guid AccountId { get; private set; } 10 | public Guid OriginalAccountId { get; private set; } 11 | public Guid ClientId { get; private set; } 12 | public IList> Ledgers { get; private set; } 13 | public string AccountName { get; private set; } 14 | public string AccountNumber { get; private set; } 15 | 16 | public ClosedAccountCreatedEvent(Guid accountId, Guid originalAccountId, Guid clientId, IList> ledgers, string accountName, string accountNumber) 17 | { 18 | AccountId = accountId; 19 | OriginalAccountId = originalAccountId; 20 | ClientId = clientId; 21 | Ledgers = ledgers; 22 | AccountName = accountName; 23 | AccountNumber = accountNumber; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/MoneyTransferFailedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class MoneyTransferFailedEvent : DomainEvent 7 | { 8 | public decimal Balance { get; private set; } 9 | public decimal Amount { get; private set; } 10 | public string TargetAccount { get; private set; } 11 | 12 | public MoneyTransferFailedEvent(decimal balance, decimal amount, string targetAccount) 13 | { 14 | Balance = balance; 15 | Amount = amount; 16 | TargetAccount = targetAccount; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/MoneyTransferReceivedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class MoneyTransferReceivedEvent : DomainEvent 7 | { 8 | public decimal Balance { get; private set; } 9 | public decimal Amount { get; private set; } 10 | public string SourceAccount { get; set; } 11 | public string TargetAccount { get; private set; } 12 | 13 | public MoneyTransferReceivedEvent(decimal balance, decimal amount, string sourceAccount, string targetAccount) 14 | { 15 | Balance = balance; 16 | Amount = amount; 17 | SourceAccount = sourceAccount; 18 | TargetAccount = targetAccount; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Account/MoneyTransferSendEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Account 4 | { 5 | [Serializable] 6 | public class MoneyTransferSendEvent : DomainEvent 7 | { 8 | public decimal Balance { get; private set; } 9 | public decimal Amount { get; private set; } 10 | public string SourceAccount { get; private set; } 11 | public string TargetAccount { get; private set; } 12 | 13 | public MoneyTransferSendEvent(decimal balance, decimal amount, string sourceAccount, string targetAccount) 14 | { 15 | Balance = balance; 16 | Amount = amount; 17 | SourceAccount = sourceAccount; 18 | TargetAccount = targetAccount; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/AccountToClientAssignedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class AccountToClientAssignedEvent : DomainEvent 7 | { 8 | public Guid AccountId { get; private set; } 9 | 10 | public AccountToClientAssignedEvent(Guid accountId) 11 | { 12 | AccountId = accountId; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/BankCardWasCanceledByCLientEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class BankCardWasCanceledByCLientEvent : DomainEvent 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/BankCardWasReportedStolenEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class BankCardWasReportedStolenEvent : DomainEvent 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/ClientCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class ClientCreatedEvent : DomainEvent 7 | { 8 | public Guid ClientId { get; private set; } 9 | public string ClientName { get; private set; } 10 | public string Street { get; private set; } 11 | public string StreetNumber { get; private set; } 12 | public string PostalCode { get; private set; } 13 | public string City { get; private set; } 14 | public string PhoneNumber { get; private set; } 15 | 16 | public ClientCreatedEvent(Guid clientId, string cLientName, string street, string streetNumber, string postalCode, string city, string phoneNumber) 17 | { 18 | ClientId = clientId; 19 | ClientName = cLientName; 20 | Street = street; 21 | StreetNumber = streetNumber; 22 | PostalCode = postalCode; 23 | City = city; 24 | PhoneNumber = phoneNumber; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/ClientMovedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class ClientMovedEvent : DomainEvent 7 | { 8 | public string Street { get; private set; } 9 | public string StreetNumber { get; private set; } 10 | public string PostalCode { get; private set; } 11 | public string City { get; private set; } 12 | 13 | public ClientMovedEvent(string street, string streetNumber, string postalCode, string city) 14 | { 15 | Street = street; 16 | StreetNumber = streetNumber; 17 | PostalCode = postalCode; 18 | City = city; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/ClientNameChangedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class ClientNameChangedEvent : DomainEvent 7 | { 8 | public string ClientName { get; private set; } 9 | 10 | public ClientNameChangedEvent(string cLientName) 11 | { 12 | ClientName = cLientName; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/ClientPhoneNumberChangedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class ClientPhoneNumberChangedEvent : DomainEvent 7 | { 8 | public string PhoneNumber { get; private set; } 9 | 10 | public ClientPhoneNumberChangedEvent(string phoneNumber) 11 | { 12 | PhoneNumber = phoneNumber; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/Client/NewBankCardForAccountAsignedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Events.Client 4 | { 5 | [Serializable] 6 | public class NewBankCardForAccountAsignedEvent : DomainEvent 7 | { 8 | public Guid BankCardId { get; private set; } 9 | public Guid AccountId { get; private set; } 10 | 11 | public NewBankCardForAccountAsignedEvent(Guid bankCardId, Guid accountId) 12 | { 13 | BankCardId = bankCardId; 14 | AccountId = accountId; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Events/DomainEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventStore; 3 | 4 | namespace Fohjin.DDD.Events 5 | { 6 | [Serializable] 7 | public class DomainEvent : IDomainEvent 8 | { 9 | public Guid Id { get; private set; } 10 | public Guid AggregateId { get; set; } 11 | int IDomainEvent.Version { get; set; } 12 | 13 | public DomainEvent() 14 | { 15 | Id = Guid.NewGuid(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting.Dto/AccountDetailsReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.Reporting.Dto 5 | { 6 | public class AccountDetailsReport 7 | { 8 | public Guid Id { get; private set; } 9 | public Guid ClientReportId { get; private set; } 10 | public IEnumerable Ledgers { get; private set; } 11 | public string AccountName { get; private set; } 12 | public decimal Balance { get; set; } 13 | public string AccountNumber { get; private set; } 14 | 15 | public AccountDetailsReport(Guid id, Guid clientId, string accountName, decimal balance, string accountNumber) 16 | { 17 | Id = id; 18 | ClientReportId = clientId; 19 | Ledgers = new List(); 20 | AccountName = accountName; 21 | Balance = balance; 22 | AccountNumber = accountNumber; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting.Dto/AccountReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Reporting.Dto 4 | { 5 | public class AccountReport 6 | { 7 | public Guid Id { get; private set; } 8 | public Guid ClientDetailsReportId { get; private set; } 9 | public string AccountName { get; private set; } 10 | public string AccountNumber { get; private set; } 11 | 12 | public AccountReport(Guid id, Guid clientDetailsId, string accountName, string accountNumber) 13 | { 14 | Id = id; 15 | ClientDetailsReportId = clientDetailsId; 16 | AccountName = accountName; 17 | AccountNumber = accountNumber; 18 | } 19 | 20 | public override string ToString() 21 | { 22 | return string.Format("{0} - ({1})", AccountNumber, AccountName); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting.Dto/ClientDetailsReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.DDD.Reporting.Dto 5 | { 6 | public class ClientDetailsReport 7 | { 8 | public Guid Id { get; private set; } 9 | public IEnumerable Accounts { get; private set; } 10 | public IEnumerable ClosedAccounts { get; private set; } 11 | public string ClientName { get; private set; } 12 | public string Street { get; private set; } 13 | public string StreetNumber { get; private set; } 14 | public string PostalCode { get; private set; } 15 | public string City { get; private set; } 16 | public string PhoneNumber { get; set; } 17 | 18 | public ClientDetailsReport(Guid id, string clientName, string street, string streetNumber, string postalCode, string city, string phoneNumber) 19 | { 20 | Id = id; 21 | Accounts = new List(); 22 | ClosedAccounts = new List(); 23 | ClientName = clientName; 24 | Street = street; 25 | StreetNumber = streetNumber; 26 | PostalCode = postalCode; 27 | City = city; 28 | PhoneNumber = phoneNumber; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting.Dto/ClientReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Reporting.Dto 4 | { 5 | public class ClientReport 6 | { 7 | public Guid Id { get; private set; } 8 | public string Name { get; private set; } 9 | 10 | public ClientReport(Guid id, string name) 11 | { 12 | Id = id; 13 | Name = name; 14 | } 15 | 16 | public override string ToString() 17 | { 18 | return Name; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting.Dto/ClosedAccountDetailsReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Reporting.Dto 4 | { 5 | public class ClosedAccountDetailsReport : AccountDetailsReport 6 | { 7 | public ClosedAccountDetailsReport(Guid id, Guid clientId, string accountName, decimal balance, string accountNumber) : base(id, clientId, accountName, balance, accountNumber) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting.Dto/ClosedAccountReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Reporting.Dto 4 | { 5 | public class ClosedAccountReport : AccountReport 6 | { 7 | public ClosedAccountReport(Guid id, Guid clientDetailsId, string name, string accountNumber) : base(id, clientDetailsId, name, accountNumber) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting.Dto/LedgerReport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Reporting.Dto 4 | { 5 | public class LedgerReport 6 | { 7 | public Guid Id { get; private set; } 8 | public Guid AccountDetailsReportId { get; private set; } 9 | public string Action { get; private set; } 10 | public decimal Amount { get; private set; } 11 | 12 | public LedgerReport(Guid id, Guid accountDetailsId, string action, decimal amount) 13 | { 14 | Id = id; 15 | AccountDetailsReportId = accountDetailsId; 16 | Action = action; 17 | Amount = amount; 18 | } 19 | 20 | public override string ToString() 21 | { 22 | return string.Format("{0} - {1:C}", Action, Amount); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting/IReportingRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Fohjin.DDD.Reporting 4 | { 5 | public interface IReportingRepository 6 | { 7 | IEnumerable GetByExample(object example) where TDto : class; 8 | void Save(TDto dto) where TDto : class; 9 | void Update(object update, object where) where TDto : class; 10 | void Delete(object example) where TDto : class; 11 | } 12 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Reporting/Infrastructure/SqlInsertBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Reflection; 3 | 4 | namespace Fohjin.DDD.Reporting.Infrastructure 5 | { 6 | public interface ISqlInsertBuilder 7 | { 8 | string CreateSqlInsertStatementFromDto() where TDto : class; 9 | } 10 | 11 | public class SqlInsertBuilder : ISqlInsertBuilder 12 | { 13 | public string CreateSqlInsertStatementFromDto() where TDto : class 14 | { 15 | return GetInsertString(); 16 | } 17 | 18 | private static string GetInsertString() 19 | { 20 | var type = typeof(TDto); 21 | var properties = type.GetProperties().Where(Where); 22 | var tableName = type.Name; 23 | 24 | return string.Format("INSERT INTO {0} ({1}) VALUES ({2});", 25 | tableName, 26 | string.Join(",", properties.Select(x => x.Name).ToArray()), 27 | string.Join(",", properties.Select(x => string.Format("@{0}", x.Name.ToLower())).ToArray())); 28 | } 29 | 30 | private static bool Where(PropertyInfo propertyInfo) 31 | { 32 | return !propertyInfo.PropertyType.IsGenericType; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Services/MoneyTransfer.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.DDD.Services 2 | { 3 | public class MoneyTransfer 4 | { 5 | public string SourceAccount { get; private set; } 6 | public string TargetAccount { get; private set; } 7 | public decimal Ammount { get; private set; } 8 | 9 | public MoneyTransfer(string sourceAccount, string targetAccount, decimal ammount) 10 | { 11 | SourceAccount = sourceAccount; 12 | TargetAccount = targetAccount; 13 | Ammount = ammount; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Services/ServicesRegister.cs: -------------------------------------------------------------------------------- 1 | using StructureMap.Configuration.DSL; 2 | 3 | namespace Fohjin.DDD.Services 4 | { 5 | public class ServicesRegister : Registry 6 | { 7 | public ServicesRegister() 8 | { 9 | ForRequestedType().TheDefault.Is.OfConcreteType(); 10 | ForRequestedType().TheDefault.Is.OfConcreteType(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin.DDD.Services/UnknownAccountException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.DDD.Services 4 | { 5 | public class UnknownAccountException : Exception 6 | { 7 | public UnknownAccountException(string message) : base(message) { } 8 | } 9 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Fohjin")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Fohjin")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("74acd944-6717-4a18-9088-336d2b947cfb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin/SystemDateTime.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin 4 | { 5 | public static class SystemDateTime 6 | { 7 | public static Func Now = () => DateTime.Now; 8 | public static void Reset() 9 | { 10 | Now = () => DateTime.Now; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Fohjin/SystemRandom.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin 4 | { 5 | public static class SystemRandom 6 | { 7 | public static Func Next = (min, max) => new Random().Next(min, max); 8 | public static void Reset() 9 | { 10 | Next = (min, max) => new Random().Next(min, max); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/Moq/Moq.Contrib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/Moq/Moq.Contrib.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/Moq/Moq.Contrib.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/Moq/Moq.Contrib.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/Moq/Moq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/Moq/Moq.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/Moq/Moq.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/Moq/Moq.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/NUnit/nunit.core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/NUnit/nunit.core.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/NUnit/nunit.core.extensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/NUnit/nunit.core.extensions.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/NUnit/nunit.core.interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/NUnit/nunit.core.interfaces.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/NUnit/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/NUnit/nunit.framework.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/NUnit/nunit.util.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/NUnit/nunit.util.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/StructureMap/StructureMap.AutoMocking.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/StructureMap/StructureMap.AutoMocking.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/StructureMap/StructureMap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/StructureMap/StructureMap.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/StructureMap/StructureMap.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/StructureMap/StructureMap.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/SQLite.Interop.065.DLL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/SQLite.Interop.065.DLL -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/SQLite.Interop.065.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/SQLite.Interop.065.exp -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/SQLite.Interop.065.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/SQLite.Interop.065.lib -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/System.Data.SQLite.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/System.Data.SQLite.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/testce.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/CompactFramework/testce.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/Designer/SQLite.Designer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/Designer/SQLite.Designer.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/Designer/install.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/Designer/install.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/Designer/install.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/ManagedOnly/System.Data.SQLite.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/ManagedOnly/System.Data.SQLite.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/ManagedOnly/readme.txt: -------------------------------------------------------------------------------- 1 | This managed version of the ADO.NET provider for SQLite requires the native 2 | sqlite3.dll or Linux shared library from http://www.sqlite.org 3 | 4 | Requires version 3.6.1 or higher. 5 | 6 | The test.exe program is a managed C# application (runs on Mono) used to test the provider's capabilities. -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/ManagedOnly/test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/ManagedOnly/test.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/ManagedOnly/test.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.DLL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.DLL -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.Linq.dll -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.exp -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/System.Data.SQLite.lib -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/itanium/System.Data.SQLite.DLL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/itanium/System.Data.SQLite.DLL -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/itanium/System.Data.SQLite.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/itanium/System.Data.SQLite.exp -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/itanium/System.Data.SQLite.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/itanium/System.Data.SQLite.lib -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/itanium/test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/itanium/test.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/itanium/test.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/linq/northwindEF.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/linq/northwindEF.db -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/linq/testlinq.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/linq/testlinq.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/linq/testlinq.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/test.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/test.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/x64/System.Data.SQLite.DLL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/x64/System.Data.SQLite.DLL -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/x64/System.Data.SQLite.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/x64/System.Data.SQLite.exp -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/x64/System.Data.SQLite.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/x64/System.Data.SQLite.lib -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/x64/test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/bin/x64/test.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/bin/x64/test.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/sqlite3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/sqlite3.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Lib/sqlite/sqlite3_analyzer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.Example/Lib/sqlite/sqlite3_analyzer.exe -------------------------------------------------------------------------------- /Fohjin.DDD.Example/ReadMe.txt: -------------------------------------------------------------------------------- 1 | # CQRS, the book 2 | 3 | In 2009 I have had the pleasure of spending a 2 day course and many geek beers with Greg Young talking about Domain-Driven Design specifically focussed on Command Query Responsibility Segregation (CQRS). 4 | 5 | The example project I created based on these discussions was very well received by the community and regarded a good reference project to explain and learn the patterns that make up CQRS. I decided to add the different blog posts I wrote about the example into a single book so it is easy to find and read. 6 | 7 | You can find the book here: https://leanpub.com/cqrs 8 | 9 | --- 10 | 11 | # x86 vs x64 12 | 13 | When running the example on a x86 machine you have to go into the /Lib/sqlite/bin/ folder 14 | and copy the three System.Data.SQLite.* files into the /Lib/sqlite/bin/x64/ folder. This 15 | is because I am developing on a x64 system. An interesting fact is that the TestDriven.Net 16 | test runner does actually run in x86 mode, so the SQLite reference in the Test project is 17 | the the x86 SQLite version already. Resharper test runner acts the same. 18 | 19 | If you have any questions or other feedback then I would love to hear about it at 20 | Mark.Nijhof@Cre8iveThought.com 21 | 22 | -Mark 23 | 24 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/AggregateRootTestFixture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.EventStore; 4 | 5 | namespace Test.Fohjin.DDD 6 | { 7 | [Specification] 8 | public abstract class AggregateRootTestFixture where TAggregateRoot : IEventProvider, new() 9 | { 10 | protected TAggregateRoot AggregateRoot; 11 | protected Exception CaughtException; 12 | protected IEnumerable PublishedEvents; 13 | protected virtual IEnumerable Given() 14 | { 15 | return new List(); 16 | } 17 | protected virtual void Finally() {} 18 | protected abstract void When(); 19 | 20 | [Given] 21 | public void Setup() 22 | { 23 | CaughtException = new ThereWasNoExceptionButOneWasExpectedException(); 24 | AggregateRoot = new TAggregateRoot(); 25 | AggregateRoot.LoadFromHistory(Given()); 26 | 27 | try 28 | { 29 | When(); 30 | PublishedEvents = AggregateRoot.GetChanges(); 31 | } 32 | catch (Exception exception) 33 | { 34 | CaughtException = exception; 35 | } 36 | finally 37 | { 38 | Finally(); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Commands/All_commands_must_be_Serializable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Fohjin.DDD.Commands; 4 | using NUnit.Framework; 5 | 6 | namespace Test.Fohjin.DDD.Commands 7 | { 8 | [TestFixture] 9 | public class All_commands_must_be_Serializable 10 | { 11 | [Test] 12 | public void All_commands_will_have_the_Serializable_attribute_assigned() 13 | { 14 | var domainEventTypes = typeof(Command).Assembly.GetExportedTypes().Where(x => x.BaseType == typeof(Command)).ToList(); 15 | foreach (var commandType in domainEventTypes) 16 | { 17 | if (commandType.IsSerializable) 18 | continue; 19 | 20 | throw new Exception(string.Format("Command '{0}' is not Serializable", commandType.FullName)); 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Commands/All_commands_must_have_a_handler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Text; 4 | using Fohjin.DDD.Configuration; 5 | using NUnit.Framework; 6 | 7 | namespace Test.Fohjin.DDD.Commands 8 | { 9 | [TestFixture] 10 | public class All_commands_must_have_a_handler 11 | { 12 | [Test] 13 | public void Verify_that_each_command_has_atleast_one_command_handler() 14 | { 15 | var commands = CommandHandlerHelper.GetCommands(); 16 | var commandHandlers = CommandHandlerHelper.GetCommandHandlers(); 17 | 18 | var stringBuilder = new StringBuilder(); 19 | foreach (var command in commands.Where(command => !commandHandlers.ContainsKey(command))) 20 | { 21 | stringBuilder.AppendLine(string.Format("No command handler found for command '{0}'", command.FullName)); 22 | continue; 23 | } 24 | if (stringBuilder.Length > 0) 25 | throw new Exception(string.Format("\n\nCommand handler exceptions:\n{0}\n", stringBuilder)); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Configuration/ApplicationBootStrapperTest.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.BankApplication; 2 | using NUnit.Framework; 3 | 4 | namespace Test.Fohjin.DDD.Configuration 5 | { 6 | [TestFixture] 7 | public class ApplicationBootStrapperTest 8 | { 9 | [Test] 10 | public void Will_be_able_to_call_the_application_boot_strapper() 11 | { 12 | ApplicationBootStrapper.BootStrap(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Configuration/DatabaseBootStrapperTest.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Fohjin.DDD.Configuration; 3 | using NUnit.Framework; 4 | 5 | namespace Test.Fohjin.DDD.Configuration 6 | { 7 | [TestFixture] 8 | public class DatabaseBootStrapperTest 9 | { 10 | [Test] 11 | public void Will_be_able_to_create_the_database_schema_in_sqlite_when_no_file_exists() 12 | { 13 | File.Delete(DomainDatabaseBootStrapper.dataBaseFile); 14 | 15 | DomainDatabaseBootStrapper.BootStrap(); 16 | } 17 | 18 | [Test] 19 | public void Will_be_able_to_create_the_database_schema_in_sqlite() 20 | { 21 | new DomainDatabaseBootStrapper().CreateDatabaseSchemaIfNeeded(); 22 | } 23 | 24 | [Test] 25 | public void Will_be_able_to_re_create_the_database_schema_in_sqlite() 26 | { 27 | new DomainDatabaseBootStrapper().ReCreateDatabaseSchema(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Configuration/ReportingBootStrapperTest.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Fohjin.DDD.Configuration; 3 | using NUnit.Framework; 4 | 5 | namespace Test.Fohjin.DDD.Configuration 6 | { 7 | [TestFixture] 8 | public class ReportingBootStrapperTest 9 | { 10 | [Test] 11 | public void Will_be_able_to_create_the_database_schema_in_sqlite_when_no_file_exists() 12 | { 13 | File.Delete(ReportingDatabaseBootStrapper.dataBaseFile); 14 | 15 | ReportingDatabaseBootStrapper.BootStrap(); 16 | } 17 | 18 | [Test] 19 | public void Will_be_able_to_create_the_database_schema_in_sqlite() 20 | { 21 | new ReportingDatabaseBootStrapper().CreateDatabaseSchemaIfNeeded(); 22 | } 23 | 24 | [Test] 25 | public void Will_be_able_to_re_create_the_database_schema_in_sqlite() 26 | { 27 | new ReportingDatabaseBootStrapper().ReCreateDatabaseSchema(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Configuration/StructureMapTest.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Configuration; 2 | using Fohjin.DDD.Services; 3 | using NUnit.Framework; 4 | using StructureMap; 5 | 6 | namespace Test.Fohjin.DDD.Configuration 7 | { 8 | [TestFixture] 9 | public class StructureMapTest 10 | { 11 | [Test] 12 | public void Will_be_able_to_re_create_the_database_schema_in_sqlite() 13 | { 14 | ObjectFactory.Initialize(x => 15 | { 16 | x.AddRegistry(); 17 | x.AddRegistry(); 18 | x.AddRegistry(); 19 | }); 20 | 21 | ObjectFactory.AssertConfigurationIsValid(); 22 | 23 | ObjectFactory.ResetDefaults(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Events/All_domain_events_must_be_Serializable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using NUnit.Framework; 4 | 5 | namespace Test.Fohjin.DDD.Events 6 | { 7 | [TestFixture] 8 | public class All_domain_events_must_be_Serializable 9 | { 10 | [Test] 11 | public void All_domain_events_will_have_the_Serializable_attribute_assigned() 12 | { 13 | var domainEventTypes = typeof(global::Fohjin.DDD.Events.DomainEvent).Assembly.GetExportedTypes().Where(x => x.BaseType == typeof(global::Fohjin.DDD.Events.DomainEvent)).ToList(); 14 | foreach (var domainEventType in domainEventTypes) 15 | { 16 | if (domainEventType.IsSerializable) 17 | continue; 18 | 19 | throw new Exception(string.Format("Domain event '{0}' is not Serializable", domainEventType.FullName)); 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Events/All_domain_events_must_have_a_handler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Text; 4 | using Fohjin.DDD.Configuration; 5 | using NUnit.Framework; 6 | 7 | namespace Test.Fohjin.DDD.Events 8 | { 9 | [TestFixture] 10 | public class All_domain_events_must_have_a_handler 11 | { 12 | [Test] 13 | public void Verify_that_each_event_has_atleast_one_event_handler() 14 | { 15 | var events = EventHandlerHelper.GetEvents(); 16 | var eventHandlers = EventHandlerHelper.GetEventHandlers(); 17 | 18 | var stringBuilder = new StringBuilder(); 19 | foreach (var theEvent in events.Where(theEvent => !eventHandlers.ContainsKey(theEvent))) 20 | { 21 | stringBuilder.AppendLine(string.Format("No event handler found for event '{0}'", theEvent.FullName)); 22 | continue; 23 | } 24 | if (stringBuilder.Length > 0) 25 | throw new Exception(string.Format("\n\nEvent handler exceptions:\n{0}\n", stringBuilder)); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Test.Fohjin.DDD")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Test.Fohjin.DDD")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("809b9c5e-f1f3-43fe-a9c5-5e37ff883b41")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Reporting/Infrastructure/SqlInsertBuilderTest.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.Reporting.Infrastructure; 2 | using NUnit.Framework; 3 | using NUnit.Framework.SyntaxHelpers; 4 | 5 | namespace Test.Fohjin.DDD.Reporting.Infrastructure 6 | { 7 | [TestFixture] 8 | public class SqlInsertBuilderTest 9 | { 10 | private SqlInsertBuilder _sqlInsertBuilder; 11 | 12 | [SetUp] 13 | public void SetUp() 14 | { 15 | _sqlInsertBuilder = new SqlInsertBuilder(); 16 | } 17 | 18 | [Test] 19 | public void When_calling_CreateSqlSelectStatementFromDto_with_a_test_dto_it_will_generate_the_expected_sql_select_with_where_clause_statement_case_1() 20 | { 21 | Assert.That(_sqlInsertBuilder.CreateSqlInsertStatementFromDto(), 22 | Is.EqualTo("INSERT INTO TestDtoCase1 (Column1,Column2,Column3) VALUES (@column1,@column2,@column3);")); 23 | } 24 | 25 | [Test] 26 | public void When_calling_CreateSqlSelectStatementFromDto_with_a_test_dto_it_will_generate_the_expected_sql_select_with_where_clause_statement_case_4() 27 | { 28 | Assert.That(_sqlInsertBuilder.CreateSqlInsertStatementFromDto(), 29 | Is.EqualTo("INSERT INTO TestDtoCase4 (Column1,Column3) VALUES (@column1,@column3);")); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Reporting/Infrastructure/TestDtoCase1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Test.Fohjin.DDD.Reporting.Infrastructure 5 | { 6 | public class TestDtoCase1 7 | { 8 | public string Column1 { get; set; } 9 | public string Column2 { get; set; } 10 | public string Column3 { get; set; } 11 | } 12 | public class TestDtoCase2 13 | { 14 | public int Column1 { get; set; } 15 | public double Column2 { get; set; } 16 | public float Column3 { get; set; } 17 | } 18 | public class TestDtoCase3 19 | { 20 | public Guid Id { get; set; } 21 | public Guid Column1 { get; set; } 22 | } 23 | public class TestDtoCase4 24 | { 25 | public string Column1 { get; set; } 26 | public List Column2 { get; set; } 27 | public string Column3 { get; set; } 28 | public IEnumerable Column4 { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Adding_a_new_client/When_in_the_GUI_adding_a_new_client.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.DDD.BankApplication.Presenters; 2 | using Fohjin.DDD.BankApplication.Views; 3 | 4 | namespace Test.Fohjin.DDD.Scenarios.Adding_a_new_client 5 | { 6 | public class When_in_the_GUI_adding_a_new_client : PresenterTestFixture 7 | { 8 | protected override void When() 9 | { 10 | On().FireEvent(x => x.OnCreateNewClient += delegate { }); 11 | } 12 | 13 | [Then] 14 | public void Then_client_report_data_from_the_reporting_repository_is_being_loaded_into_the_view() 15 | { 16 | On().VerifyThat.Method(x => x.SetClient(null)).WasCalled(); 17 | } 18 | 19 | [Then] 20 | public void Then_display_will_be_called_on_the_view() 21 | { 22 | On().VerifyThat.Method(x => x.Display()).WasCalled(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Assign_new_bank_card/When_assigning_a_new_bank_card_on_a_non_existing_client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Client; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Assign_new_bank_card 7 | { 8 | public class When_assigning_a_new_bank_card_on_a_non_existing_client : CommandTestFixture 9 | { 10 | private readonly Guid _accountId = Guid.NewGuid(); 11 | private readonly Guid _clientId = Guid.NewGuid(); 12 | 13 | protected override AssignNewBankCardCommand When() 14 | { 15 | return new AssignNewBankCardCommand(_clientId, _accountId); 16 | } 17 | 18 | [Then] 19 | public void Then_a_non_existing_account_exception_will_be_thrown() 20 | { 21 | CaughtException.WillBeOfType(); 22 | } 23 | 24 | [Then] 25 | public void Then_the_exception_message_will_be() 26 | { 27 | CaughtException.Message.WillBe("The Client is not created and no opperations can be executed on it"); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Changing_the_name_of_an_account/When_changing_the_name_of_a_closed_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Changing_the_name_of_an_account 10 | { 11 | public class When_changing_the_name_of_a_closed_account : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | yield return PrepareDomainEvent.Set(new AccountClosedEvent()).ToVersion(2); 17 | } 18 | 19 | protected override ChangeAccountNameCommand When() 20 | { 21 | return new ChangeAccountNameCommand(Guid.NewGuid(), "New Account Name"); 22 | } 23 | 24 | [Then] 25 | public void Then_a_closed_account_exception_will_be_thrown() 26 | { 27 | CaughtException.WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_exception_message_will_be() 32 | { 33 | CaughtException.Message.WillBe("The ActiveAcount is closed and no opperations can be executed on it"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Changing_the_name_of_an_account/When_changing_the_name_of_a_non_existing_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Changing_the_name_of_an_account 7 | { 8 | public class When_changing_the_name_of_a_non_existing_account : CommandTestFixture 9 | { 10 | protected override ChangeAccountNameCommand When() 11 | { 12 | return new ChangeAccountNameCommand(Guid.NewGuid(), "New Account Name"); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_account_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The ActiveAcount is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Changing_the_name_of_an_account/When_changing_the_name_of_an_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Fohjin.DDD.CommandHandlers; 5 | using Fohjin.DDD.Commands; 6 | using Fohjin.DDD.Domain.Account; 7 | using Fohjin.DDD.Events.Account; 8 | using Fohjin.DDD.EventStore; 9 | 10 | namespace Test.Fohjin.DDD.Scenarios.Changing_the_name_of_an_account 11 | { 12 | public class When_changing_the_name_of_an_account : CommandTestFixture 13 | { 14 | protected override IEnumerable Given() 15 | { 16 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 17 | } 18 | 19 | protected override ChangeAccountNameCommand When() 20 | { 21 | return new ChangeAccountNameCommand(Guid.NewGuid(), "New Account Name"); 22 | } 23 | 24 | [Then] 25 | public void Then_an_account_name_changed_event_will_be_published() 26 | { 27 | PublishedEvents.Last().WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_published_event_will_contain_the_new_name_of_the_account() 32 | { 33 | PublishedEvents.Last().AccountName.WillBe("New Account Name"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_got_a_new_phone_number/When_changing_the_phone_number.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Fohjin.DDD.CommandHandlers; 5 | using Fohjin.DDD.Commands; 6 | using Fohjin.DDD.Domain.Client; 7 | using Fohjin.DDD.Events.Client; 8 | using Fohjin.DDD.EventStore; 9 | 10 | namespace Test.Fohjin.DDD.Scenarios.Client_got_a_new_phone_number 11 | { 12 | public class When_changing_the_phone_number : CommandTestFixture 13 | { 14 | protected override IEnumerable Given() 15 | { 16 | yield return PrepareDomainEvent.Set(new ClientCreatedEvent(Guid.NewGuid(), "Mark Nijhof", "Welhavens gate", "49b", "5006", "Bergen", "95009937")).ToVersion(1); 17 | } 18 | 19 | protected override ChangeClientPhoneNumberCommand When() 20 | { 21 | return new ChangeClientPhoneNumberCommand(Guid.NewGuid(), "95009937"); 22 | } 23 | 24 | [Then] 25 | public void Then_a_client_phone_number_changed_event_will_be_published() 26 | { 27 | PublishedEvents.Last().WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_published_event_will_contain_the_new_phone_number_of_the_client() 32 | { 33 | PublishedEvents.Last().PhoneNumber.WillBe("95009937"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_got_a_new_phone_number/When_changing_the_phone_number_of_a_non_existing_client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Client; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Client_got_a_new_phone_number 7 | { 8 | public class When_changing_the_phone_number_of_a_non_existing_client : CommandTestFixture 9 | { 10 | protected override ChangeClientPhoneNumberCommand When() 11 | { 12 | return new ChangeClientPhoneNumberCommand(Guid.NewGuid(), "95009937"); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_client_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The Client is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_got_his_name_changed/When_changing_the_name_of_a_client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Fohjin.DDD.CommandHandlers; 5 | using Fohjin.DDD.Commands; 6 | using Fohjin.DDD.Domain.Client; 7 | using Fohjin.DDD.Events.Client; 8 | using Fohjin.DDD.EventStore; 9 | 10 | namespace Test.Fohjin.DDD.Scenarios.Client_got_his_name_changed 11 | { 12 | public class When_changing_the_name_of_a_client : CommandTestFixture 13 | { 14 | protected override IEnumerable Given() 15 | { 16 | yield return PrepareDomainEvent.Set(new ClientCreatedEvent(Guid.NewGuid(), "Mark Nijhof", "Welhavens gate", "49b", "5006", "Bergen", "95009937")).ToVersion(1); 17 | } 18 | 19 | protected override ChangeClientNameCommand When() 20 | { 21 | return new ChangeClientNameCommand(Guid.NewGuid(), "Mark Nijhof"); 22 | } 23 | 24 | [Then] 25 | public void Then_a_client_name_changed_event_will_be_published() 26 | { 27 | PublishedEvents.Last().WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_published_event_will_contain_the_new_name_of_the_client() 32 | { 33 | PublishedEvents.Last().ClientName.WillBe("Mark Nijhof"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_got_his_name_changed/When_changing_the_name_of_a_non_existing_client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Client; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Client_got_his_name_changed 7 | { 8 | public class When_changing_the_name_of_a_non_existing_client : CommandTestFixture 9 | { 10 | protected override ChangeClientNameCommand When() 11 | { 12 | return new ChangeClientNameCommand(Guid.NewGuid(), "Mark Nijhof"); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_client_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The Client is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_moved/When_a_non_existing_client_is_moving.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Client; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Client_moved 7 | { 8 | public class When_a_non_existing_client_is_moving : CommandTestFixture 9 | { 10 | protected override ClientIsMovingCommand When() 11 | { 12 | return new ClientIsMovingCommand(Guid.NewGuid(), "Welhavens gate", "49b", "5006", "Bergen"); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_client_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The Client is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_wants_to_close_an_account/When_an_account_was_closed.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventHandlers; 3 | using Fohjin.DDD.Events.Account; 4 | using Fohjin.DDD.Reporting; 5 | using Fohjin.DDD.Reporting.Dto; 6 | using Moq; 7 | 8 | namespace Test.Fohjin.DDD.Scenarios.Client_wants_to_close_an_account 9 | { 10 | public class When_an_account_was_closed : EventTestFixture 11 | { 12 | protected override AccountClosedEvent When() 13 | { 14 | return new AccountClosedEvent { AggregateId = Guid.NewGuid() }; 15 | } 16 | 17 | [Then] 18 | public void Then_the_reporting_repository_will_be_used_to_update_the_account_report() 19 | { 20 | OnDependency().Verify(x => x.Delete(It.IsAny()), Times.Once()); 21 | } 22 | 23 | [Then] 24 | public void Then_the_reporting_repository_will_be_used_to_update_the_account_details_report() 25 | { 26 | OnDependency().Verify(x => x.Delete(It.IsAny()), Times.Once()); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_wants_to_close_an_account/When_closing_a_closed_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Client_wants_to_close_an_account 10 | { 11 | public class When_closing_a_closed_account : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | yield return PrepareDomainEvent.Set(new AccountClosedEvent()).ToVersion(2); 17 | } 18 | 19 | protected override CloseAccountCommand When() 20 | { 21 | return new CloseAccountCommand(Guid.NewGuid()); 22 | } 23 | 24 | [Then] 25 | public void Then_a_closed_account_exception_will_be_thrown() 26 | { 27 | CaughtException.WillBeOfType(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_wants_to_close_an_account/When_closing_a_non_existing_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Client_wants_to_close_an_account 7 | { 8 | public class When_closing_a_non_existing_account : CommandTestFixture 9 | { 10 | protected override CloseAccountCommand When() 11 | { 12 | return new CloseAccountCommand(Guid.NewGuid()); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_account_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_wants_to_close_an_account/When_closing_an_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Fohjin.DDD.CommandHandlers; 5 | using Fohjin.DDD.Commands; 6 | using Fohjin.DDD.Domain.Account; 7 | using Fohjin.DDD.Events.Account; 8 | using Fohjin.DDD.EventStore; 9 | using Moq; 10 | 11 | namespace Test.Fohjin.DDD.Scenarios.Client_wants_to_close_an_account 12 | { 13 | public class When_closing_an_account : CommandTestFixture 14 | { 15 | protected override IEnumerable Given() 16 | { 17 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 18 | } 19 | 20 | protected override CloseAccountCommand When() 21 | { 22 | return new CloseAccountCommand(Guid.NewGuid()); 23 | } 24 | 25 | [Then] 26 | public void Then_an_account_closed_event_will_be_published() 27 | { 28 | PublishedEvents.Last().WillBeOfType(); 29 | } 30 | 31 | [Then] 32 | public void Then_the_newly_created_closed_account_will_be_saved() 33 | { 34 | OnDependency>().Verify(x => x.Add(It.IsAny())); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_wants_to_close_an_account/When_closing_an_account_with_a_positive_balance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Client_wants_to_close_an_account 10 | { 11 | public class When_closing_an_account_with_a_positive_balance : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | yield return PrepareDomainEvent.Set(new CashDepositedEvent(20, 20)).ToVersion(1); 17 | } 18 | 19 | protected override CloseAccountCommand When() 20 | { 21 | return new CloseAccountCommand(Guid.NewGuid()); 22 | } 23 | 24 | [Then] 25 | public void Then_an_account_balance_not_zero_exception_will_be_thrown() 26 | { 27 | CaughtException.WillBeOfType(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_wants_to_open_a_new_account/When_an_account_was_assigned_to_a_client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.EventHandlers; 3 | using Fohjin.DDD.Events.Client; 4 | 5 | namespace Test.Fohjin.DDD.Scenarios.Client_wants_to_open_a_new_account 6 | { 7 | public class When_an_account_was_assigned_to_a_client : EventTestFixture 8 | { 9 | protected override AccountToClientAssignedEvent When() 10 | { 11 | return new AccountToClientAssignedEvent(Guid.NewGuid()) { AggregateId = Guid.NewGuid() }; 12 | } 13 | 14 | [Then] 15 | public void Then_it_will_not_throw_an_exception() 16 | { 17 | CaughtException.WillBeOfType(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Client_wants_to_open_a_new_account/When_opening_a_new_account_for_a_non_existing_client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | using Fohjin.DDD.Domain.Client; 6 | using Fohjin.DDD.EventStore; 7 | using Moq; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Client_wants_to_open_a_new_account 10 | { 11 | public class When_opening_a_new_account_for_a_non_existing_client : CommandTestFixture 12 | { 13 | protected override OpenNewAccountForClientCommand When() 14 | { 15 | return new OpenNewAccountForClientCommand(Guid.NewGuid(), "New Account"); 16 | } 17 | 18 | [Then] 19 | public void Then_a_non_existing_client_exception_will_be_thrown() 20 | { 21 | CaughtException.WillBeOfType(); 22 | } 23 | 24 | [Then] 25 | public void Then_the_exception_message_will_be() 26 | { 27 | CaughtException.Message.WillBe("The Client is not created and no opperations can be executed on it"); 28 | } 29 | 30 | [Then] 31 | public void Then_there_is_no_new_account_to_be_saved() 32 | { 33 | OnDependency>().Verify(x => x.Add(It.IsAny()), Times.Never()); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Depositing_cash/When_depositing_cash.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Fohjin.DDD.CommandHandlers; 5 | using Fohjin.DDD.Commands; 6 | using Fohjin.DDD.Domain.Account; 7 | using Fohjin.DDD.Events.Account; 8 | using Fohjin.DDD.EventStore; 9 | 10 | namespace Test.Fohjin.DDD.Scenarios.Depositing_cash 11 | { 12 | public class When_depositing_cash : CommandTestFixture 13 | { 14 | protected override IEnumerable Given() 15 | { 16 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 17 | yield return PrepareDomainEvent.Set(new CashDepositedEvent(10, 10)).ToVersion(2); 18 | } 19 | 20 | protected override DepositeCashCommand When() 21 | { 22 | return new DepositeCashCommand(Guid.NewGuid(), 20); 23 | } 24 | 25 | [Then] 26 | public void Then_a_cash_deposited_event_will_be_published() 27 | { 28 | PublishedEvents.Last().WillBeOfType(); 29 | } 30 | 31 | [Then] 32 | public void Then_the_published_event_will_contain_the_amount_and_new_account_balance() 33 | { 34 | PublishedEvents.Last().Balance.WillBe(30); 35 | PublishedEvents.Last().Amount.WillBe(20); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Depositing_cash/When_depositing_cash_on_a_closed_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Depositing_cash 10 | { 11 | public class When_depositing_cash_on_a_closed_account : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | yield return PrepareDomainEvent.Set(new AccountClosedEvent()).ToVersion(2); 17 | } 18 | 19 | protected override DepositeCashCommand When() 20 | { 21 | return new DepositeCashCommand(Guid.NewGuid(), 0); 22 | } 23 | 24 | [Then] 25 | public void Then_a_closed_account_exception_will_be_thrown() 26 | { 27 | CaughtException.WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_exception_message_will_be() 32 | { 33 | CaughtException.Message.WillBe("The ActiveAcount is closed and no opperations can be executed on it"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Depositing_cash/When_depositing_cash_on_a_non_existing_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Depositing_cash 7 | { 8 | public class When_depositing_cash_on_a_non_existing_account : CommandTestFixture 9 | { 10 | protected override DepositeCashCommand When() 11 | { 12 | return new DepositeCashCommand(Guid.NewGuid(), 0); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_account_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The ActiveAcount is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Displaying_the_error_popup/When_in_the_GUI_displaying_the_error_popup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.BankApplication.Presenters; 3 | using Fohjin.DDD.BankApplication.Views; 4 | 5 | namespace Test.Fohjin.DDD.Scenarios.Displaying_the_error_popup 6 | { 7 | public class When_in_the_GUI_displaying_the_error_popup : PresenterTestFixture 8 | { 9 | protected override void When() 10 | { 11 | Presenter.CatchPossibleException(() => 12 | { 13 | throw new Exception("Message"); 14 | }); 15 | } 16 | 17 | [Then] 18 | public void Then_the_name_of_the_exception_is_loaded_in_the_view() 19 | { 20 | On().VerifyThat.ValueIsSetFor(x => x.Exception = "Exception"); 21 | } 22 | 23 | [Then] 24 | public void Then_the_message_of_the_exception_is_loaded_in_the_view() 25 | { 26 | On().VerifyThat.ValueIsSetFor(x => x.Message = "Message"); 27 | } 28 | 29 | [Then] 30 | public void Then_display_is_called() 31 | { 32 | On().VerifyThat.Method(x => x.ShowDialog()).WasCalled(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Opening_the_bank_application/Opening_the_application.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.BankApplication.Presenters; 4 | using Fohjin.DDD.BankApplication.Views; 5 | using Fohjin.DDD.Reporting; 6 | using Fohjin.DDD.Reporting.Dto; 7 | 8 | namespace Test.Fohjin.DDD.Scenarios.Opening_the_bank_application 9 | { 10 | public class When_in_the_GUI_openeing_the_bank_application : PresenterTestFixture 11 | { 12 | private List _clientReports; 13 | 14 | protected override void SetupDependencies() 15 | { 16 | _clientReports = new List { new ClientReport(Guid.NewGuid(), "Client Name") }; 17 | OnDependency() 18 | .Setup(x => x.GetByExample(null)) 19 | .Returns(_clientReports); 20 | } 21 | 22 | protected override void When() 23 | { 24 | Presenter.Display(); 25 | } 26 | 27 | [Then] 28 | public void Then_show_dialog_will_be_called_on_the_view() 29 | { 30 | On().VerifyThat.Method(x => x.ShowDialog()).WasCalled(); 31 | } 32 | 33 | [Then] 34 | public void Then_client_report_data_from_the_reporting_repository_is_being_loaded_into_the_view() 35 | { 36 | On().VerifyThat.ValueIsSetFor(x => x.Clients = _clientReports); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Receiving_money_transfer/When_receiveing_a_money_transfer_for_a_closed_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Receiving_money_transfer 10 | { 11 | public class When_receiveing_a_money_transfer_for_a_closed_account : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | yield return PrepareDomainEvent.Set(new AccountClosedEvent()).ToVersion(2); 17 | } 18 | 19 | protected override ReceiveMoneyTransferCommand When() 20 | { 21 | return new ReceiveMoneyTransferCommand(Guid.NewGuid(), 10.0M, "1234567890"); 22 | } 23 | 24 | [Then] 25 | public void Then_a_closed_account_exception_will_be_thrown() 26 | { 27 | CaughtException.WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_exception_message_will_be() 32 | { 33 | CaughtException.Message.WillBe("The ActiveAcount is closed and no opperations can be executed on it"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Receiving_money_transfer/When_receiveing_a_money_transfer_for_a_non_existing_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Receiving_money_transfer 7 | { 8 | public class When_receiveing_a_money_transfer_for_a_non_existing_account : CommandTestFixture 9 | { 10 | protected override ReceiveMoneyTransferCommand When() 11 | { 12 | return new ReceiveMoneyTransferCommand(Guid.NewGuid(), 10.0M, "1234567890"); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_account_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The ActiveAcount is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Receiving_money_transfer/When_receiving_a_money_transfer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.Bus; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Reporting; 6 | using Fohjin.DDD.Reporting.Dto; 7 | using Fohjin.DDD.Services; 8 | using Moq; 9 | 10 | namespace Test.Fohjin.DDD.Scenarios.Receiving_money_transfer 11 | { 12 | public class When_receiving_a_money_transfer : BaseTestFixture 13 | { 14 | protected override void SetupDependencies() 15 | { 16 | OnDependency() 17 | .Setup(x => x.GetByExample(It.IsAny())) 18 | .Returns(new List { new AccountReport(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "target account number") }); 19 | } 20 | 21 | protected override void When() 22 | { 23 | SubjectUnderTest.Receive(new MoneyTransfer("source account number", "target account number", 123.45M)); 24 | } 25 | 26 | [Then] 27 | public void Then_the_newly_created_account_will_be_saved() 28 | { 29 | OnDependency().Verify(x => x.Publish(It.IsAny())); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Receiving_money_transfer/When_receiving_a_money_transfer_for_an_unknown_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.Reporting; 3 | using Fohjin.DDD.Reporting.Dto; 4 | using Fohjin.DDD.Services; 5 | using Moq; 6 | 7 | namespace Test.Fohjin.DDD.Scenarios.Receiving_money_transfer 8 | { 9 | public class When_receiving_a_money_transfer_for_an_unknown_account : BaseTestFixture 10 | { 11 | protected override void SetupDependencies() 12 | { 13 | OnDependency() 14 | .Setup(x => x.GetByExample(It.IsAny())) 15 | .Throws(new Exception("account not found")); 16 | } 17 | 18 | protected override void When() 19 | { 20 | SubjectUnderTest.Receive(new MoneyTransfer("source account number", "target account number", 123.45M)); 21 | } 22 | 23 | [Then] 24 | public void Then_the_newly_created_account_will_be_saved() 25 | { 26 | CaughtException.WillBeOfType(); 27 | } 28 | 29 | [Then] 30 | public void Then_the_exception_message_will_be() 31 | { 32 | CaughtException.Message.WillBe(string.Format("The requested account '{0}' is not managed by this bank", "target account number")); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Transfering_money/When_compensating_a_failed_money_transfer_from_a_non_existing_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Transfering_money 7 | { 8 | public class When_compensating_a_failed_money_transfer_from_a_non_existing_account : CommandTestFixture 9 | { 10 | protected override MoneyTransferFailedCompensatingCommand When() 11 | { 12 | return new MoneyTransferFailedCompensatingCommand(Guid.NewGuid(), 5.0M, "0987654321"); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_account_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The ActiveAcount is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Transfering_money/When_sending_a_money_transfer_from_a_closed_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Transfering_money 10 | { 11 | public class When_sending_a_money_transfer_from_a_closed_account : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | yield return PrepareDomainEvent.Set(new AccountClosedEvent()).ToVersion(2); 17 | } 18 | 19 | protected override SendMoneyTransferCommand When() 20 | { 21 | return new SendMoneyTransferCommand(Guid.NewGuid(), 10.0M, "1234567890"); 22 | } 23 | 24 | [Then] 25 | public void Then_a_closed_account_exception_will_be_thrown() 26 | { 27 | CaughtException.WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_exception_message_will_be() 32 | { 33 | CaughtException.Message.WillBe("The ActiveAcount is closed and no opperations can be executed on it"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Transfering_money/When_sending_a_money_transfer_from_a_non_existing_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Transfering_money 7 | { 8 | public class When_sending_a_money_transfer_from_a_non_existing_account : CommandTestFixture 9 | { 10 | protected override SendMoneyTransferCommand When() 11 | { 12 | return new SendMoneyTransferCommand(Guid.NewGuid(), 10.0M, "1234567890"); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_account_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The ActiveAcount is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Transfering_money/When_sending_a_money_transfer_from_an_account_with_to_little_balance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Transfering_money 10 | { 11 | public class When_sending_a_money_transfer_from_an_account_with_to_little_balance : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | } 17 | 18 | protected override SendMoneyTransferCommand When() 19 | { 20 | return new SendMoneyTransferCommand(Guid.NewGuid(), 10.5M, "1234567890"); 21 | } 22 | 23 | [Then] 24 | public void Then_an_account_balance_to_low_exception_will_be_thrown() 25 | { 26 | CaughtException.WillBeOfType(); 27 | } 28 | 29 | [Then] 30 | public void Then_the_exception_message_will_be() 31 | { 32 | CaughtException.WithMessage(string.Format("The amount {0:C} is larger than your current balance {1:C}", 10.5M, 0)); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Withdrawing_cash/When_withdrawing_cash.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Fohjin.DDD.CommandHandlers; 5 | using Fohjin.DDD.Commands; 6 | using Fohjin.DDD.Domain.Account; 7 | using Fohjin.DDD.Events.Account; 8 | using Fohjin.DDD.EventStore; 9 | 10 | namespace Test.Fohjin.DDD.Scenarios.Withdrawing_cash 11 | { 12 | public class When_withdrawing_cash : CommandTestFixture 13 | { 14 | protected override IEnumerable Given() 15 | { 16 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 17 | yield return PrepareDomainEvent.Set(new CashDepositedEvent(20, 20)).ToVersion(1); 18 | } 19 | 20 | protected override WithdrawlCashCommand When() 21 | { 22 | return new WithdrawlCashCommand(Guid.NewGuid(), 5); 23 | } 24 | 25 | [Then] 26 | public void Then_a_cash_withdrawn_event_will_be_published() 27 | { 28 | PublishedEvents.Last().WillBeOfType(); 29 | } 30 | 31 | [Then] 32 | public void Then_the_published_event_will_contain_the_amount_and_new_account_balance() 33 | { 34 | PublishedEvents.Last().Balance.WillBe(15); 35 | PublishedEvents.Last().Amount.WillBe(5); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Withdrawing_cash/When_withdrawling_cash_from_a_closed_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Withdrawing_cash 10 | { 11 | public class When_withdrawling_cash_from_a_closed_account : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | yield return PrepareDomainEvent.Set(new AccountClosedEvent()).ToVersion(2); 17 | } 18 | 19 | protected override WithdrawlCashCommand When() 20 | { 21 | return new WithdrawlCashCommand(Guid.NewGuid(), 0); 22 | } 23 | 24 | [Then] 25 | public void Then_a_closed_account_exception_will_be_thrown() 26 | { 27 | CaughtException.WillBeOfType(); 28 | } 29 | 30 | [Then] 31 | public void Then_the_exception_message_will_be() 32 | { 33 | CaughtException.Message.WillBe("The ActiveAcount is closed and no opperations can be executed on it"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Withdrawing_cash/When_withdrawling_cash_from_a_non_existing_account.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Fohjin.DDD.CommandHandlers; 3 | using Fohjin.DDD.Commands; 4 | using Fohjin.DDD.Domain.Account; 5 | 6 | namespace Test.Fohjin.DDD.Scenarios.Withdrawing_cash 7 | { 8 | public class When_withdrawling_cash_from_a_non_existing_account : CommandTestFixture 9 | { 10 | protected override WithdrawlCashCommand When() 11 | { 12 | return new WithdrawlCashCommand(Guid.NewGuid(), 0); 13 | } 14 | 15 | [Then] 16 | public void Then_a_non_existing_account_exception_will_be_thrown() 17 | { 18 | CaughtException.WillBeOfType(); 19 | } 20 | 21 | [Then] 22 | public void Then_the_exception_message_will_be() 23 | { 24 | CaughtException.Message.WillBe("The ActiveAcount is not created and no opperations can be executed on it"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Fohjin.DDD.Example/Test.Fohjin.DDD/Scenarios/Withdrawing_cash/When_withdrawling_cash_from_an_account_account_with_to_little_balance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.DDD.CommandHandlers; 4 | using Fohjin.DDD.Commands; 5 | using Fohjin.DDD.Domain.Account; 6 | using Fohjin.DDD.Events.Account; 7 | using Fohjin.DDD.EventStore; 8 | 9 | namespace Test.Fohjin.DDD.Scenarios.Withdrawing_cash 10 | { 11 | public class When_withdrawling_cash_from_an_account_account_with_to_little_balance : CommandTestFixture 12 | { 13 | protected override IEnumerable Given() 14 | { 15 | yield return PrepareDomainEvent.Set(new AccountOpenedEvent(Guid.NewGuid(), Guid.NewGuid(), "AccountName", "1234567890")).ToVersion(1); 16 | } 17 | 18 | protected override WithdrawlCashCommand When() 19 | { 20 | return new WithdrawlCashCommand(Guid.NewGuid(), 1); 21 | } 22 | 23 | [Then] 24 | public void Then_an_account_balance_to_low_exception_will_be_thrown() 25 | { 26 | CaughtException.WillBeOfType(); 27 | } 28 | 29 | [Then] 30 | public void Then_the_exception_message_will_be() 31 | { 32 | CaughtException.WithMessage(string.Format("The amount {0:C} is larger than your current balance {1:C}", 1, 0)); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fohjin.EventStore", "Fohjin.EventStore\Fohjin.EventStore.csproj", "{8DB1E26D-388E-48EC-AAD6-85E8A12E7D5A}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Fohjin.EventStore", "Test.Fohjin.EventStore\Test.Fohjin.EventStore.csproj", "{CD4A1CFC-5451-4C10-9313-221F2D0A343C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8DB1E26D-388E-48EC-AAD6-85E8A12E7D5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8DB1E26D-388E-48EC-AAD6-85E8A12E7D5A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8DB1E26D-388E-48EC-AAD6-85E8A12E7D5A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8DB1E26D-388E-48EC-AAD6-85E8A12E7D5A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {CD4A1CFC-5451-4C10-9313-221F2D0A343C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {CD4A1CFC-5451-4C10-9313-221F2D0A343C}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {CD4A1CFC-5451-4C10-9313-221F2D0A343C}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {CD4A1CFC-5451-4C10-9313-221F2D0A343C}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Configuration/ApprovedEntitiesCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.EventStore.Configuration 5 | { 6 | public class ApprovedEntitiesCache 7 | { 8 | private readonly List _cache; 9 | 10 | public ApprovedEntitiesCache() 11 | { 12 | _cache = new List(); 13 | } 14 | 15 | public void RegisterApprovedEntity(Type entityType) 16 | { 17 | _cache.Add(entityType); 18 | } 19 | 20 | public bool IsEntityApproved(Type entityType) 21 | { 22 | return _cache.Contains(entityType); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Configuration/EventProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace Fohjin.EventStore.Configuration 6 | { 7 | public class EventProcessor 8 | { 9 | public Type RegisteredEvent { get; private set; } 10 | public PropertyInfo Property { get; private set; } 11 | public Action> ProcessorEventProperty { get; private set; } 12 | 13 | public EventProcessor(Type registeredEvent, PropertyInfo property, Action> eventPropertyProcessor) 14 | { 15 | RegisteredEvent = registeredEvent; 16 | Property = property; 17 | ProcessorEventProperty = eventPropertyProcessor; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Configuration/EventProcessorCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Fohjin.EventStore.Configuration 5 | { 6 | public class EventProcessorCache 7 | { 8 | private readonly Dictionary> _cache; 9 | 10 | public EventProcessorCache() 11 | { 12 | _cache = new Dictionary>(); 13 | } 14 | 15 | public bool TryGetEventProcessorsFor(Type domainEventType, out IEnumerable eventProcessors) 16 | { 17 | return _cache.TryGetValue(domainEventType, out eventProcessors); 18 | } 19 | 20 | public void RegisterEventProcessors(Type domainEventType, IEnumerable eventProcessors) 21 | { 22 | if (_cache.ContainsKey(domainEventType)) 23 | return; 24 | 25 | _cache.Add(domainEventType, eventProcessors); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Configuration/MethodMissingException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.EventStore.Configuration 4 | { 5 | public class MethodMissingException : Exception 6 | { 7 | public MethodMissingException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Configuration/PreProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Fohjin.EventStore.Reflection; 4 | 5 | namespace Fohjin.EventStore.Configuration 6 | { 7 | public class PreProcessor 8 | { 9 | private readonly EventProcessorCache _eventProcessorCache; 10 | private readonly EventAccessor _eventAccessor; 11 | private readonly List _registeredEventTypes; 12 | 13 | public PreProcessor(EventProcessorCache eventProcessorCache, EventAccessor eventAccessor) 14 | { 15 | _eventProcessorCache = eventProcessorCache; 16 | _eventAccessor = eventAccessor; 17 | _registeredEventTypes = new List(); 18 | } 19 | 20 | public void RegisterForPreProcessing() 21 | { 22 | RegisterForPreProcessing(typeof(TEvent)); 23 | } 24 | 25 | public void RegisterForPreProcessing(Type eventType) 26 | { 27 | _registeredEventTypes.Add(eventType); 28 | } 29 | 30 | public void Process() 31 | { 32 | _registeredEventTypes.ForEach(ProcessEvent); 33 | } 34 | 35 | private void ProcessEvent(Type eventType) 36 | { 37 | _eventProcessorCache.RegisterEventProcessors(eventType, _eventAccessor.BuildEventProcessors(eventType)); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/IDomainEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.EventStore 4 | { 5 | public interface IDomainEvent 6 | { 7 | Guid EventId { get; } 8 | Guid AggregateId { get; set; } 9 | int EventVersion { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/IDomainRepository.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.EventStore.Infrastructure; 2 | 3 | namespace Fohjin.EventStore 4 | { 5 | public interface IDomainRepository 6 | { 7 | TAggregateRoot CreateNew() where TAggregateRoot : class; 8 | 9 | //TAggregate GetById(Guid id) 10 | // where TAggregate : class, IOrginator, IEventProvider, new(); 11 | 12 | //void Add(TAggregate aggregateRoot) 13 | // where TAggregate : class, IOrginator, IEventProvider, new(); 14 | } 15 | 16 | public class DomainRepository : IDomainRepository 17 | { 18 | private readonly IAggregateRootFactory _aggregateRootFactory; 19 | 20 | public DomainRepository(IAggregateRootFactory aggregateRootFactory) 21 | { 22 | _aggregateRootFactory = aggregateRootFactory; 23 | } 24 | 25 | public TAggregateRoot CreateNew() where TAggregateRoot : class 26 | { 27 | return _aggregateRootFactory.Create(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/IMemento.cs: -------------------------------------------------------------------------------- 1 | namespace Fohjin.EventStore 2 | { 3 | public interface IMemento 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Infrastructure/IOrginator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.EventStore.Infrastructure 4 | { 5 | public interface IOrginator 6 | { 7 | IMemento CreateMemento(); 8 | void SetMemento(IMemento memento); 9 | } 10 | 11 | public class Orginator : IOrginator 12 | { 13 | public IMemento CreateMemento() 14 | { 15 | throw new NotImplementedException(); 16 | } 17 | 18 | public void SetMemento(IMemento memento) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Infrastructure/IlligalStateAssignmentException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.EventStore.Infrastructure 4 | { 5 | public class IlligalStateAssignmentException : Exception 6 | { 7 | public IlligalStateAssignmentException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Infrastructure/UnregisteredDomainEventException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fohjin.EventStore.Infrastructure 4 | { 5 | public class UnregisteredDomainEventException : Exception 6 | { 7 | public UnregisteredDomainEventException(string message) : base(message) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Fohjin.EventStore/Reflection/EventPropertyLocator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace Fohjin.EventStore.Reflection 7 | { 8 | public class EventPropertyLocator 9 | { 10 | public IEnumerable RetrieveDomainEventProperties(Type registeredEvent) 11 | { 12 | return registeredEvent 13 | .GetProperties(BindingFlags.Instance | BindingFlags.Public) 14 | .Where(x => !GetBaseInterfaceProperties().Contains(x.Name)); 15 | } 16 | 17 | private static List GetBaseInterfaceProperties() 18 | { 19 | return typeof(IDomainEvent).GetProperties().Select(x => x.Name).ToList(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_an_event_gets_published.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Fohjin.EventStore; 3 | using Fohjin.EventStore.Configuration; 4 | using Fohjin.EventStore.Infrastructure; 5 | 6 | namespace Test.Fohjin.EventStore.Infrastructure 7 | { 8 | public class When_an_event_gets_published : BaseTestFixture 9 | { 10 | private TestClient _testClient; 11 | 12 | protected override void Given() 13 | { 14 | var eventProcessorCache = PreProcessorHelper.CreateEventProcessorCache(); 15 | _testClient = new DomainRepository(new AggregateRootFactory(eventProcessorCache, new ApprovedEntitiesCache())).CreateNew(); 16 | } 17 | 18 | protected override void When() 19 | { 20 | _testClient.ClientMoves(new Address("street", "number", "postalCode", "city")); 21 | } 22 | 23 | [Then] 24 | public void Then_the_internal_collection_of_events_will_contain_the_published_event() 25 | { 26 | var eventProvider = (IEventProvider) _testClient; 27 | eventProvider.GetChanges().Count().WillBe(1); 28 | eventProvider.GetChanges().First().WillBeOfType(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_an_unregistered_event_gets_published.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.EventStore; 2 | using Fohjin.EventStore.Configuration; 3 | using Fohjin.EventStore.Infrastructure; 4 | 5 | namespace Test.Fohjin.EventStore.Infrastructure 6 | { 7 | public class When_an_unregistered_event_gets_published : BaseTestFixture 8 | { 9 | private TestClient _testClient; 10 | 11 | protected override void Given() 12 | { 13 | _testClient = new DomainRepository(new AggregateRootFactory(new EventProcessorCache(), new ApprovedEntitiesCache())).CreateNew(); 14 | } 15 | 16 | protected override void When() 17 | { 18 | _testClient.ClientMoves(new Address("street", "number", "postalCode", "city")); 19 | } 20 | 21 | [Then] 22 | public void The_an_exception_will_be_thrown() 23 | { 24 | CaughtException.WillBeOfType(); 25 | } 26 | 27 | [Then] 28 | public void The_exception_message_will_be() 29 | { 30 | CaughtException.Message.WillBe(string.Format("The requested class '{0}' is not registered as a domain event", typeof(ClientMovedEvent).FullName)); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_executing_behavior_that_diretly_sets_the_internal_state.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.EventStore; 2 | using Fohjin.EventStore.Configuration; 3 | using Fohjin.EventStore.Infrastructure; 4 | 5 | namespace Test.Fohjin.EventStore.Infrastructure 6 | { 7 | public class When_executing_behavior_that_diretly_sets_the_internal_state : BaseTestFixture 8 | { 9 | private TestClient _testClient; 10 | 11 | protected override void Given() 12 | { 13 | _testClient = new DomainRepository(new AggregateRootFactory(new EventProcessorCache(), new ApprovedEntitiesCache())).CreateNew(); 14 | } 15 | 16 | protected override void When() 17 | { 18 | _testClient.ClientMovesIlligalAction(new Address("street", "123", "5000", "Bergen")); 19 | } 20 | 21 | [Then] 22 | public void The_an_exception_will_be_thrown() 23 | { 24 | CaughtException.WillBeOfType(); 25 | } 26 | 27 | [Then] 28 | public void The_exception_message_will_be() 29 | { 30 | CaughtException.Message.WillBe(string.Format("Internal state is not allowed to be altered directly using property '{0}' and should always be done through the publishing of an event!", "Address")); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_loading_an_empty_history_event_collection.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Collections.Generic; 3 | using Fohjin.EventStore; 4 | using Fohjin.EventStore.Configuration; 5 | using Fohjin.EventStore.Infrastructure; 6 | 7 | namespace Test.Fohjin.EventStore.Infrastructure 8 | { 9 | public class When_loading_an_empty_history_event_collection : BaseTestFixture 10 | { 11 | private TestClient _testClient; 12 | 13 | protected override void Given() 14 | { 15 | var eventProcessorCache = PreProcessorHelper.CreateEventProcessorCache(); 16 | _testClient = new DomainRepository(new AggregateRootFactory(eventProcessorCache, new ApprovedEntitiesCache())).CreateNew(); 17 | } 18 | 19 | protected override void When() 20 | { 21 | var eventProvider = (IEventProvider)_testClient; 22 | eventProvider.LoadFromHistory(new List()); 23 | } 24 | 25 | [Then] 26 | public void Then_the_internal_collection_publiched_of_events_will_be_empty() 27 | { 28 | var eventProvider = (IEventProvider) _testClient; 29 | eventProvider.GetChanges().Count().WillBe(0); 30 | } 31 | 32 | [Then] 33 | public void Then_the_state_of_the_entity_is_not_updated() 34 | { 35 | _testClient.GetAddress().WillBe(null); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_requesting_a_new_object_from_the_repository.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.EventStore; 2 | using Fohjin.EventStore.Configuration; 3 | using Fohjin.EventStore.Infrastructure; 4 | 5 | namespace Test.Fohjin.EventStore.Infrastructure 6 | { 7 | public class When_requesting_a_new_object_from_the_repository : BaseTestFixture 8 | { 9 | private TestClient _testClient; 10 | 11 | protected override void When() 12 | { 13 | _testClient = new DomainRepository(new AggregateRootFactory(new EventProcessorCache(), new ApprovedEntitiesCache())).CreateNew(); 14 | } 15 | 16 | [Then] 17 | public void The_created_object_will_not_be_null() 18 | { 19 | _testClient.WillNotBe(null); 20 | } 21 | 22 | [Then] 23 | public void The_created_object_will_be_of_the_requested_type() 24 | { 25 | _testClient.WillActLikeType(); 26 | } 27 | 28 | [Then] 29 | public void The_created_object_will_implement_the_IEventProvider_interface() 30 | { 31 | _testClient.WillImplementInterface(); 32 | } 33 | 34 | [Then] 35 | public void The_created_object_will_implement_the_IOrginator_interface() 36 | { 37 | _testClient.WillImplementInterface(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_requesting_a_new_object_from_the_repository_that_has_no_virtual_apply_method.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.EventStore; 2 | using Fohjin.EventStore.Configuration; 3 | using Fohjin.EventStore.Infrastructure; 4 | 5 | namespace Test.Fohjin.EventStore.Infrastructure 6 | { 7 | public class When_requesting_a_new_object_from_the_repository_that_has_no_proteced_virtual_apply_method_declared : BaseTestFixture 8 | { 9 | protected override void When() 10 | { 11 | new DomainRepository(new AggregateRootFactory(new EventProcessorCache(), new ApprovedEntitiesCache())).CreateNew(); 12 | } 13 | 14 | [Then] 15 | public void The_an_exception_will_be_thrown() 16 | { 17 | CaughtException.WillBeOfType(); 18 | } 19 | 20 | [Then] 21 | public void The_exception_message_will_be() 22 | { 23 | CaughtException.Message.WillBe(string.Format("Object '{0}' needs to have a 'proteced virtual void Apply(object @event)' method declared", typeof(TestObjectWithoutApplyMethod).FullName)); 24 | } 25 | } 26 | 27 | public class TestObjectWithoutApplyMethod 28 | { 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_the_internal_collection_of_published_events_gets_cleared.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Fohjin.EventStore; 3 | using Fohjin.EventStore.Configuration; 4 | using Fohjin.EventStore.Infrastructure; 5 | 6 | namespace Test.Fohjin.EventStore.Infrastructure 7 | { 8 | public class When_the_internal_collection_of_published_events_gets_cleared : BaseTestFixture 9 | { 10 | private TestClient _testClient; 11 | 12 | protected override void Given() 13 | { 14 | var eventProcessorCache = PreProcessorHelper.CreateEventProcessorCache(); 15 | _testClient = new DomainRepository(new AggregateRootFactory(eventProcessorCache, new ApprovedEntitiesCache())).CreateNew(); 16 | _testClient.ClientMoves(new Address("street", "number", "postalCode", "city")); 17 | } 18 | 19 | protected override void When() 20 | { 21 | var eventProvider = (IEventProvider)_testClient; 22 | eventProvider.Clear(); 23 | } 24 | 25 | [Then] 26 | public void Then_the_internal_collection_of_events_will_contain_the_published_event() 27 | { 28 | var eventProvider = (IEventProvider) _testClient; 29 | eventProvider.GetChanges().Count().WillBe(0); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Fohjin.EventStore/Test.Fohjin.EventStore/Infrastructure/When_updating_the_version.cs: -------------------------------------------------------------------------------- 1 | using Fohjin.EventStore; 2 | using Fohjin.EventStore.Configuration; 3 | using Fohjin.EventStore.Infrastructure; 4 | 5 | namespace Test.Fohjin.EventStore.Infrastructure 6 | { 7 | public class When_updating_the_version : BaseTestFixture 8 | { 9 | private TestClient _testClient; 10 | 11 | protected override void Given() 12 | { 13 | var eventProcessorCache = PreProcessorHelper.CreateEventProcessorCache(); 14 | _testClient = new DomainRepository(new AggregateRootFactory(eventProcessorCache, new ApprovedEntitiesCache())).CreateNew(); 15 | } 16 | 17 | protected override void When() 18 | { 19 | var eventProvider = (IEventProvider)_testClient; 20 | eventProvider.UpdateVersion(10); 21 | } 22 | 23 | [Then] 24 | public void Then_the_version_will_be_updated() 25 | { 26 | var eventProvider = (IEventProvider) _testClient; 27 | eventProvider.Version.WillBe(10); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.Core.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.Core.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.Core.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.DynamicProxy2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.DynamicProxy2.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.DynamicProxy2.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/CastleDynamicProxy/Castle.DynamicProxy2.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/Moq/Moq.Contrib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/Moq/Moq.Contrib.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/Moq/Moq.Contrib.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/Moq/Moq.Contrib.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/Moq/Moq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/Moq/Moq.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/Moq/Moq.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/Moq/Moq.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.core.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.core.extensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.core.extensions.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.core.interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.core.interfaces.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.framework.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.util.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/NUnit/nunit.util.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/StructureMap/StructureMap.AutoMocking.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/StructureMap/StructureMap.AutoMocking.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/StructureMap/StructureMap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/StructureMap/StructureMap.dll -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/StructureMap/StructureMap.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/StructureMap/StructureMap.pdb -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/sqlite/sqlite3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/sqlite/sqlite3.exe -------------------------------------------------------------------------------- /Fohjin.DDD.MakeReusable/Lib/sqlite/sqlite3_analyzer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkNijhof/Fohjin/e22c7e147f682c73032aa4f6a8295c63d9c13185/Fohjin.DDD.MakeReusable/Lib/sqlite/sqlite3_analyzer.exe -------------------------------------------------------------------------------- /ReadMe.txt: -------------------------------------------------------------------------------- 1 | # CQRS, the book 2 | 3 | In 2009 I have had the pleasure of spending a 2 day course and many geek beers with Greg Young talking about Domain-Driven Design specifically focussed on Command Query Responsibility Segregation (CQRS). 4 | 5 | The example project I created based on these discussions was very well received by the community and regarded a good reference project to explain and learn the patterns that make up CQRS. I decided to add the different blog posts I wrote about the example into a single book so it is easy to find and read. 6 | 7 | You can find the book here: https://leanpub.com/cqrs 8 | 9 | --- 10 | 11 | # x86 vs x64 12 | 13 | When running the example on a x86 machine you have to go into the /Lib/sqlite/bin/ folder 14 | and copy the three System.Data.SQLite.* files into the /Lib/sqlite/bin/x64/ folder. This 15 | is because I am developing on a x64 system. An interesting fact is that the TestDriven.Net 16 | test runner does actually run in x86 mode, so the SQLite reference in the Test project is 17 | the the x86 SQLite version already. Resharper test runner acts the same. 18 | 19 | If you have any questions or other feedback then I would love to hear about it at 20 | Mark.Nijhof@Cre8iveThought.com 21 | 22 | -Mark 23 | 24 | --------------------------------------------------------------------------------