Пример #1
0
        public void GIVEN_aggregate_root_id_WHEN_creating_an_event_THEN_initializes_event_with_given_aggregate_root_id_AND_initial_version(string aggregateRootId)
        {
            // Act
            var @event = new BehaviorExecuted(aggregateRootId);

            // Assert
            @event.AggregateRootId
            .Should()
            .BeEquivalentTo(aggregateRootId);

            @event.Version
            .Should()
            .Be(Constants.INITIAL_VERSION);
        }
Пример #2
0
        public void GIVEN_invalid_aggregate_root_version_WHEN_incrementing_event_version_THEN_throws_AggregateRootException(string aggregateRootId)
        {
            // Arrange
            long aggregateRootVersion = -2;

            // Act
            var @event = new BehaviorExecuted(aggregateRootId);

            var action = @event.Invoking(_ => @event.IncrementVersion(ref aggregateRootVersion));

            // Assert
            action
            .Should()
            .Throw <AggregateRootVersionException>();
        }
Пример #3
0
        public void GIVEN_aggregate_root_version_WHEN_incrementing_event_version_THEN_increments_aggregate_root_version(string aggregateRootId)
        {
            // Arrange
            var aggregateRootVersion = Constants.INITIAL_VERSION;

            const long EXPECTED_AGGREGATE_ROOT_VERSION = Constants.INITIAL_VERSION + 1;

            // Act
            var @event = new BehaviorExecuted(aggregateRootId);

            @event.IncrementVersion(ref aggregateRootVersion);

            // Assert
            aggregateRootVersion
            .Should()
            .Be(EXPECTED_AGGREGATE_ROOT_VERSION);

            @event.Version
            .Should()
            .Be(EXPECTED_AGGREGATE_ROOT_VERSION);
        }