public void AddDomainEventWithValidVersionThenVersionOfEventShouldBeEqualsToCurrentVerSionOfAggregate()
        {
            //Arrange
            long         expectedVersion = -1;
            IDomainEvent @event          = new SubEvent(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <string>());
            var          sut             = CreateNewAggregate <StubEventSourcing>();

            //Act
            sut.ExposeAddDomainEvent(@event, expectedVersion);

            //Assert
            Assert.Equal(sut.Version, @event.AggregateVersion);
        }
        public void AddDomainEventWithValidVersionThenEventShouldBeAppliedToAggregate()
        {
            //Arrange
            long expectedVersion = -1;

            var sut    = CreateNewAggregate <StubEventSourcing>();
            var @event = new SubEvent(Guid.NewGuid(), sut.Id, "test value");

            //Act
            sut.ExposeAddDomainEvent(@event, expectedVersion);

            //Assert
            Assert.Equal(sut.Id, @event.AggregateId);
            Assert.Equal(sut.Value, @event.Value);
        }
        public void AddDomainEventWithValidVersionThenUncommittedEventsShouldBeSingle()
        {
            //Arrange
            long expectedVersion = -1;

            var sut    = CreateNewAggregate <StubEventSourcing>();
            var @event = new SubEvent(Guid.NewGuid(), sut.Id, "test value");

            //Act
            sut.ExposeAddDomainEvent(@event, expectedVersion);
            var uncommittedEvents = sut.GetUncommittedEvents().Single();

            //Assert
            Assert.NotNull(uncommittedEvents);
            Assert.Equal(uncommittedEvents, @event);
        }
        public void ClearUncommittedEventsThenUncommittedEventsShouldBeEmpty()
        {
            //Arrange
            long expectedVersion = -1;

            var sut    = CreateNewAggregate <StubEventSourcing>();
            var @event = new SubEvent(Guid.NewGuid(), sut.Id, "test value");

            //Act
            sut.ExposeAddDomainEvent(@event, expectedVersion);
            sut.ClearUncommittedEvents();
            var uncommittedEvents = sut.GetUncommittedEvents();

            //Assert
            Assert.NotNull(uncommittedEvents);
            Assert.Empty(uncommittedEvents);
        }
 public void Apply(SubEvent subEvent)
 {
     Value = subEvent.Value;
 }