public void Verify_generation_of_events()
 {
     TestClassForAggregateRoot sut = new TestClassForAggregateRoot();
     var evts = ((IEventSourcedEntity)sut).GetRaisedEvents();
     evts.Should().Have.Count.EqualTo(1);
     evts.Single().Should().Be.OfType<TestClassForAggregateRootCreated>();
 }
 public void verify_clear_of_events()
 {
     TestClassForAggregateRoot sut = new TestClassForAggregateRoot();
     ((IEventSourcedEntity)sut).ClearRaisedEvents();
     var evts = ((IEventSourcedEntity)sut).GetRaisedEvents();
     evts.Should().Have.Count.EqualTo(0);
 }
 public void verify_get_back_whole_stream_of_events()
 {
     TestClassForAggregateRoot entity = new TestClassForAggregateRoot();
     sut.Save(entity);
     sut.Commit(Guid.NewGuid());
     var loaded = sut.GetById<TestClassForAggregateRoot>(entity.Id);
     loaded.Id.Should().Be.EqualTo(entity.Id);
 }
 public void verify_base_save_and_load()
 {
     TestClassForAggregateRoot entity = new TestClassForAggregateRoot();
     sut.Save(entity);
     sut.Commit(Guid.NewGuid());
     var loaded = sut.GetById<TestClassForAggregateRoot>(entity.Id);
     loaded.Id.Should().Be.EqualTo(entity.Id);
 }
 public void Verify_basic_ability_of_event_reapplier()
 {
     TestClassForAggregateRoot sut = new TestClassForAggregateRoot();
     var evt = new TestClassForAggregateRootCreated() {
         IntProperty = 42,
         StringProperty = "42",
     };
     ((IEventSourcedEntity)sut).ApplyEvent(evt);
     sut.IntProperty.Should().Be.EqualTo(42);
     sut.StringProperty.Should().Be.EqualTo("42");
     sut.Id.Should().Be.EqualTo(evt.Id);
 }
        public void verify_save_get_modify_save()
        {
            TestClassForAggregateRoot entity = new TestClassForAggregateRoot();
            entity.Increment(10);
            sut.Save(entity);
            sut.Commit(Guid.NewGuid());
            var loaded = sut.GetById<TestClassForAggregateRoot>(entity.Id);
            loaded.Increment(32);
            sut.Commit(Guid.NewGuid());

            var reloaded = sut.GetById<TestClassForAggregateRoot>(entity.Id);
            reloaded.IntProperty.Should().Be.EqualTo(42);
        }
        public void verify_commit_will_now_modify_aggregateRoots_after_previous_commit_without_explicit_load()
        {
            TestClassForAggregateRoot entity = new TestClassForAggregateRoot();
            entity.Increment(10);
            sut.Save(entity);
            sut.Commit(Guid.NewGuid());

            //Now increment the entity, but the old unit of work was committed, this entity should not tracked anymore
            entity.Increment(32);
            sut.Commit(Guid.NewGuid());

            var loaded = sut.GetById<TestClassForAggregateRoot>(entity.Id);
            loaded.IntProperty.Should().Be.EqualTo(10);
        }