public void Setup()
 {
     _connectionString = ConfigurationManager.AppSettings["MongoEventStoreConnectionString"];
     _database = ConfigurationManager.AppSettings["MongoEventStoreDatabaseName"];
     var mockPublisher = MockRepository.GenerateMock<IEventPublisher>();
     var eventPersistence = new MongoEventPersistence(_connectionString, _database);
     _domainRepository = new DomainRepository(new EventStore(eventPersistence, mockPublisher));
 }
Ejemplo n.º 2
0
 public void When()
 {
     var repositoryFactory = new DomainRepositoryStubFactory();
     _blogRepository = repositoryFactory.GetDomainRepository<Blog>();
     _blogCommandHandlers = new BlogCommandHandlers(repositoryFactory);
     _createBlogCommand = new CreateBlogCommand("Title", "SubTitle", Guid.Empty, Guid.Empty);
     _blogCommandHandlers.Handle(_createBlogCommand);
 }
        public StudentsAppService(IDomainRepository<Student> studentsRepository)
        {
            if (studentsRepository == null)
            {
                throw new Exception("studentsRepository");
            }

            this._studentsRepository = studentsRepository;
        }
Ejemplo n.º 4
0
        public CoursesAppService(IDomainRepository<Course> coursesRepository)
        {
            if (coursesRepository == null)
            {
                throw  new ArgumentNullException("coursesRepository");
            }

            this._coursesRepository = coursesRepository;
        }
Ejemplo n.º 5
0
 public JoesUnitOfWork(Guid commandId, IDomainRepository domainRepository, IStoreEvents eventStore, ISnapshotStore snapshotStore, IEventBus eventBus, ISnapshottingPolicy snapshottingPolicy)
     : base(commandId)
 {
     _eventStream = new UncommittedEventStream(commandId);
     _commitId = commandId;
     _eventStore = eventStore;
     _domainRepository = domainRepository;
     _snapshotStore = snapshotStore;
     _eventBus = eventBus;
     _snapshottingPolicy = snapshottingPolicy;
 }
Ejemplo n.º 6
0
        public void SetUp()
        {
            new DomainDatabaseBootStrapper().ReCreateDatabaseSchema();

            var sqliteConnectionString = string.Format("Data Source={0}", dataBaseFile);

            _domainEventStorage = new DomainEventStorage(sqliteConnectionString, new BinaryFormatter());
            _eventStoreIdentityMap = new EventStoreIdentityMap();
            _eventStoreUnitOfWork = new EventStoreUnitOfWork(_domainEventStorage, _eventStoreIdentityMap, new Mock<IBus>().Object);
            _repository = new DomainRepository(_eventStoreUnitOfWork, _eventStoreIdentityMap);
        }
Ejemplo n.º 7
0
        public UnitOfWork(Guid commandId, IDomainRepository domainRepository, IEventStore eventStore, ISnapshotStore snapshotStore, IEventBus eventBus, ISnapshottingPolicy snapshottingPolicy) : base(commandId)
        {
            Contract.Requires<ArgumentNullException>(domainRepository != null);
            Contract.Requires<ArgumentNullException>(snapshotStore != null);
            Contract.Requires<ArgumentNullException>(eventStore != null);
            Contract.Requires<ArgumentNullException>(eventBus != null);
            Contract.Requires<ArgumentNullException>(snapshottingPolicy != null);

            _repository = domainRepository;
            _snapshottingPolicy = snapshottingPolicy;
            _eventBus = eventBus;
            _snapshotStore = snapshotStore;
            _eventStore = eventStore;
            _eventStream = new UncommittedEventStream(commandId);
            _dirtyInstances = new Queue<AggregateRoot>();
        }
Ejemplo n.º 8
0
 public DomainService(
     ICoreScopeProvider provider,
     ILoggerFactory loggerFactory,
     IEventMessagesFactory eventMessagesFactory,
     IDomainRepository domainRepository)
     : base(provider, loggerFactory, eventMessagesFactory) =>
 public EventSourcingDomainRepositoryTests()
 {
     this.repository = new EventSourcingDomainRepository(eventStore, eventPublisher);
 }
Ejemplo n.º 10
0
 public CreateCategoryCommandHandler(IDomainRepository repository)
 {
     _repository = repository;
 }
 public IssuesController(IDomainRepository domainRepository, IUserSession userSession)
 {
     _domainRepository = domainRepository;
     _userSession = userSession;
 }
Ejemplo n.º 12
0
 public BaseIdentityEventHandler(IIdentityReportDataAccessor reportDataAccessor, ICommandTracker commandTracker, ILogger logger, IDomainRepository domainRepository, IEventPublisher eventPublisher) : base(commandTracker, logger)
 {
     _reportDataAccessor = reportDataAccessor;
     _domainRepository   = domainRepository;
     _eventPublisher     = eventPublisher;
 }
Ejemplo n.º 13
0
 public BaseInventoryCommandHandler(IDomainRepository domainRepository, IInventoryReportDataAccessor dataAccesor, ICommandTracker tracker, ILogger logger) : base(tracker, logger)
 {
     _domainRepository = domainRepository;
     _dataAccessor     = dataAccesor;
 }
 /// <summary>
 /// Initializes a domain context
 /// </summary>
 public DomainContext(IEventBus eventBus, IEventStore eventStore, ISnapshotStore snapshotStore, IDomainRepository domainRepository)
 {
     _eventStore    = eventStore;
     _eventBus      = eventBus;
     _snapshotStore = snapshotStore;
     _repository    = domainRepository;
 }
Ejemplo n.º 15
0
        public async Task Given_An_Aggregate_Which_Has_Been_Saved_When_A_Snapshot_Is_Taken_Then_The_Aggregate_Can_Be_Loaded_From_The_Latest_Snapshot_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_Which_Has_Been_Saved_When_A_Snapshot_Is_Taken_Then_The_Aggregate_Can_Be_Loaded_From_The_Latest_Snapshot(domainRepository, LoadAggregateAsync(domainRepository)).ConfigureAwait(false);
        }
Ejemplo n.º 16
0
        public async Task Given_An_Aggregate_With_Two_Events_That_Have_The_Same_Id_When_Saving_A_Snapshot_Then_The_Revision_Should_Be_One_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_With_Two_Events_That_Have_The_Same_Id_When_Saving_A_Snapshot_Then_The_Revision_Should_Be_One(domainRepository, LoadAggregateAsync(domainRepository)).ConfigureAwait(false);
        }
 public void Release(IDomainRepository repository)
 {
     ServiceLocator.Current.Release(repository);
 }
Ejemplo n.º 18
0
 public DomainService(IDomainRepository domainRepository)
 {
     _domainRepository = domainRepository;
 }
Ejemplo n.º 19
0
 public AllCommandHandlers(IDomainRepository domainRepository)
 {
     _domainRepository = domainRepository;
 }
		public IssuesController(IUserSession userSession, IDomainRepository repository)
		{
			_userSession = userSession;
			_repository = repository;
		}
 public void Release(IDomainRepository repository)
 {
     _locator.Release(repository);
 }
Ejemplo n.º 22
0
        public void SetUp()
        {
            sut = new SnapShotService();

            bus = MockRepository.GenerateMock<IBus>();
            eventConvertor = MockRepository.GenerateMock<IEventConvertor>();

            var entityRepository = new InMemoryEntityRepository();
            domainRepository = new DomainRepository(new DomainEventStorageService(entityRepository, new DateTimeService()), bus, eventConvertor);
        }
Ejemplo n.º 23
0
        public async Task Given_An_Aggregate_With_Events_When_A_Snapshot_Is_Taken_Then_The_Number_Of_Events_Since_Last_Snapshot_Count_Is_One_Before_The_Snapshot_And_Zero_After_The_Snapshot_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_With_Events_When_A_Snapshot_Is_Taken_Then_The_Number_Of_Events_Since_Last_Snapshot_Count_Is_One_Before_The_Snapshot_And_Zero_After_The_Snapshot(domainRepository).ConfigureAwait(false);
        }
Ejemplo n.º 24
0
 public ProjectController(ISourceControlManager sourceControlManager, IDomainRepository<Project> projectRepository)
 {
     _sourceControlManager = sourceControlManager;
     _projectRepository = projectRepository;
 }
Ejemplo n.º 25
0
        public async Task Given_An_Aggregate_With_A_Stream_And_Snapshot_At_The_End_Of_The_Stream_When_The_Aggregate_Is_Loaded_From_The_Snapshot_And_Saved_Then_The_Number_Of_Events_Since_Last_Snapshot_Is_One_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_With_A_Stream_And_Snapshot_At_The_End_Of_The_Stream_When_The_Aggregate_Is_Loaded_From_The_Snapshot_And_Saved_Then_The_Number_Of_Events_Since_Last_Snapshot_Is_One(domainRepository, LoadAggregateAsync(domainRepository)).ConfigureAwait(false);
        }
Ejemplo n.º 26
0
 public PutBlockCommandHandler(IDomainRepository repository)
 {
     _repository = repository;
 }
Ejemplo n.º 27
0
        public async Task Should_Correctly_Count_Number_Of_Events_Since_Last_Snapshot_And_Load_From_Latest_Snapshot_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Should_Correctly_Count_Number_Of_Events_Since_Last_Snapshot_And_Load_From_Latest_Snapshot(domainRepository).ConfigureAwait(false);
        }
Ejemplo n.º 28
0
 private static Func <TestAggregate, Task> LoadAggregateAsync(IDomainRepository domainRepository)
 {
     return(domainRepository.LoadFromLatestSnapshotAsync);
 }
Ejemplo n.º 29
0
 public RemoteFacade(IDomainRepository repository, IAggregateRootCreationStrategy factory)
 {
     _repository = repository;
     _factory = factory;
 }
Ejemplo n.º 30
0
        public async Task Given_An_Aggregate_That_Has_Been_Saved_And_Had_A_Snapshot_Saved_And_Had_Subsequent_Events_Committed_When_The_Aggregate_Is_Loaded_From_The_Snapshot_Then_The_Aggregate_State_Includes_The_Events_Committed_After_The_Snapshot_Was_Saved_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_That_Has_Been_Saved_And_Had_A_Snapshot_Saved_And_Had_Subsequent_Events_Committed_When_The_Aggregate_Is_Loaded_From_The_Snapshot_Then_The_Aggregate_State_Includes_The_Events_Committed_After_The_Snapshot_Was_Saved(domainRepository, LoadAggregateAsync(domainRepository)).ConfigureAwait(false);
        }
Ejemplo n.º 31
0
 public DomainService(IDomainRepository domainRepository)
 {
     _domainRepository = domainRepository;
 }
Ejemplo n.º 32
0
        public async Task Given_An_Aggregate_That_Has_Been_Saved_And_Had_A_Snapshot_Saved_When_The_Aggregate_Is_Loaded_From_The_Snapshot_Then_The_Aggregate_Loads_From_The_Snapshot_With_No_Additional_Events_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_That_Has_Been_Saved_And_Had_A_Snapshot_Saved_When_The_Aggregate_Is_Loaded_From_The_Snapshot_Then_The_Aggregate_Loads_From_The_Snapshot_With_No_Additional_Events(domainRepository, LoadAggregateAsync(domainRepository)).ConfigureAwait(false);
        }
 /// <summary>
 /// NServiceBus.Host receives AddLocationCommand and finds the
 /// class implementing IHandleMessages<AddLocationCommand>
 ///
 /// It then creates an instance of this class and uses the settings
 /// in EndpointConfig.cs to inject an instance of EventSourceDomainRepository
 /// in depositRepository property. NServiceBus proceeds to run the
 /// Handle(AddLocation message) methods parsing in the methid sent from the
 /// LocationController across the bus
 ///
 /// In this example NServiceBus is self hosted in a command Windows
 /// and when it first loads it scans in EndpointConfig.cs if present
 ///
 /// </summary>
 public AddLocationHandler()
 {
     domainRepository = (IDomainRepository)UnityConfig.GetConfiguredContainer().Resolve(typeof(IDomainRepository));
 }
Ejemplo n.º 34
0
        public async Task Given_An_Aggregate_Loaded_From_A_Snapshot_Then_The_Number_Of_Events_Since_Last_Snapshot_Count_Is_Zero_After_The_Load_And_One_After_An_Update_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_Loaded_From_A_Snapshot_Then_The_Number_Of_Events_Since_Last_Snapshot_Count_Is_Zero_After_The_Load_And_One_After_An_Update(domainRepository, LoadAggregateAsync(domainRepository)).ConfigureAwait(false);
        }
Ejemplo n.º 35
0
 public GetDocumentQueryHandler(IFileRepository fileRepository, IDomainRepository domainRepository)
 {
     this.fileRepository   = fileRepository;
     this.domainRepository = domainRepository;
 }
Ejemplo n.º 36
0
        public async Task Given_An_Aggregate_Throughout_The_Lifecycle_When_The_Number_Of_Events_Since_Last_Snapshot_Checked_Then_It_Reports_The_Correct_Value_For_Load_From_Latest()
        {
            IDomainRepository domainRepository = GetDomainRepository();

            await this.Given_An_Aggregate_Throughout_The_Lifecycle_When_The_Number_Of_Events_Since_Last_Snapshot_Checked_Then_It_Reports_The_Correct_Value(domainRepository, LoadAggregateAsync(domainRepository)).ConfigureAwait(false);
        }
Ejemplo n.º 37
0
 public InStoreBookInventoryCommandHandler(IDomainRepository domainRepository, IInventoryReportDataAccessor dataAccesor, ICommandTracker tracker, ILogger logger) : base(domainRepository, dataAccesor, tracker, logger)
 {
 }
Ejemplo n.º 38
0
 public AllCommandHandlers(IDomainRepository domainRepository)
 {
     _domainRepository = domainRepository;
 }
Ejemplo n.º 39
0
        /// <summary>
        /// Allows you to chain mutator functions to run after execution of a query.
        /// </summary>
        /// <typeparam name="TResult">Query result type.</typeparam>
        /// <param name="query">Query to mutate.</param>
        /// <returns>A query context that allows chaining of mutator functions.</returns>
        public static IDomainRepositoryQueryContext <TResult> WithQuery <TResult>(this IDomainRepository domainRepository, IQuery <TResult> query)
        {
            var extendableContentRepository = domainRepository.AsExtendableContentRepository();

            return(DomainRepositoryQueryContextFactory.Create(query, extendableContentRepository));
        }
Ejemplo n.º 40
0
 public TestAggregateThing(IDomainRepository repository)
 {
     this.repository = repository;
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Used to manage transactions for multiple domain commands.
        /// This abstraction is an enhanced version of
        /// System.Transaction.TransactionScope and works in the same way.
        /// </summary>
        public static IDomainRepositoryTransactionManager Transactions(this IDomainRepository domainRepository)
        {
            var extendedContentRepositry = domainRepository.AsExtendableContentRepository();

            return(extendedContentRepositry.ServiceProvider.GetRequiredService <IDomainRepositoryTransactionManager>());
        }
Ejemplo n.º 42
0
 public ReturnBookRequestCreatedEventHandler(IInventoryReportDataAccessor reportDataAccessor, ICommandTracker commandTracker, ILogger logger, IDomainRepository domainRepository, IEventPublisher eventPublisher) : base(reportDataAccessor, commandTracker, logger, domainRepository, eventPublisher)
 {
 }
Ejemplo n.º 43
0
 public GetDomainByName(IDomainRepository domainRepository)
 {
     this.domainRepository = domainRepository;
 }
Ejemplo n.º 44
0
 public FeatureApplicationServices(IDomainRepository repository)
 {
     this.repository = repository;
 }
Ejemplo n.º 45
0
 public CourseNameChangerHandler(IDomainRepository <Domain.CourseModule.Course> domainRepository)
 {
     _domainRepository = domainRepository;
 }
 public DomainServiceImplementation(ILibraryConfiguration xXXLibraryConfiguration, IDomainRepository domainRepository)
 {
     _domainRepository = domainRepository;
 }
Ejemplo n.º 47
0
 public DomainService(IScopeProvider provider, ILogger logger, IEventMessagesFactory eventMessagesFactory,
                      IDomainRepository domainRepository)
     : base(provider, logger, eventMessagesFactory)
 {
     _domainRepository = domainRepository;
 }
Ejemplo n.º 48
0
 public DashboardController(IDomainRepository<Project> projectRepository, IDomainRepository<NewsItem> newsItemRepository)
 {
     _projectRepository = projectRepository;
     _newsItemRepository = newsItemRepository;
 }
Ejemplo n.º 49
0
 public AuthorizationService(IDomainRepository<UserPermission> permissionsRepository)
 {
     _permissionsRepository = permissionsRepository;
 }