Inheritance: AggregateRoot
        public void Throws_exception_when_applying_unknown_event_on_aggregate_root()
        {
            var entity = new SomeDomainEntity();
            var domainEvent = new SomeDomainEvent();

            entity.Apply(domainEvent);
        }
Beispiel #2
0
        public void Can_track_aggregate()
        {
            var session = new Session(this, this);
            var aggregate = new SomeDomainEntity();

            session.Track(aggregate);
        }
Beispiel #3
0
        public void Can_get_tracked_aggregate()
        {
            var session = new Session(this, this);
            var aggregate = new SomeDomainEntity();

            session.Track(aggregate);

            var loadedAggregate = session.GetAggregateIfTracked<SomeDomainEntity>(aggregate.Id);

            loadedAggregate.ShouldNotBeNull();
            loadedAggregate.ShouldBeSameAs(aggregate);
        }
Beispiel #4
0
        public void Loads_aggregate_from_session_if_tracked()
        {
            var trackedAggregate = new SomeDomainEntity();

            var session = new Session(this, this);
            session.Track(trackedAggregate);

            var repository = new Repository<SomeDomainEntity>(this, session);

            var loadedAggregate = repository.GetById(trackedAggregate.Id);

            loadedAggregate.ShouldBeSameAs(trackedAggregate);
        }
Beispiel #5
0
        public void Loads_aggregate_From_eventstore_if_not_tracked()
        {
            var untrackedAggregate = new SomeDomainEntity();
            var session = new Session(this, this);
            _aggregateToLoad = untrackedAggregate;

            var repository = new Repository<SomeDomainEntity>(this, session);

            var loadedAggregate = repository.GetById(untrackedAggregate.Id);

            loadedAggregate.ShouldBeSameAs(_aggregateToLoad);
            session.GetAggregateIfTracked<SomeDomainEntity>(untrackedAggregate.Id).ShouldNotBeNull("Aggregate should have been added to session");
        }