public void Load_WhenAnAggregatorLoadsEventsFromHistory_ThenTheAggregatorShouldUpdateWithTheDetailsOfTheEvents
        (
            Guid id,
            string mockProperty,
            MockAggregator mockAggregator,
            IEvent mockEvent
        )
        {
            "Given an aggregate"
            .x(() => mockAggregator = _fixture.Create <MockAggregator>());

            "And an aggregate Id"
            .x(() => id = _fixture.Create <Guid>());

            "And an event loaded from the event store"
            .x(() =>
            {
                mockProperty = _fixture.Create <string>();
                mockEvent    = new MockPropertyChangedEvent(id, mockProperty);
            });

            "And the event has the correct version"
            .x(() => mockEvent.Version = 1);

            "When the aggregator loads the event"
            .x(() => mockAggregator.Load(new[] { mockEvent }));

            "Then the aggregator is updated with the details of the event"
            .x(() =>
            {
                mockAggregator.Id.Should().Be(id);
                mockAggregator.MockProperty.Should().Be(mockProperty);
                mockAggregator.Version.Should().Be(mockEvent.Version);
            });
        }
Пример #2
0
        public void Fetch_WhenTheEventsFromTheEventStoreAreFetchedAndLoadedToTheAggregator_ThenTheAggregatorShouldBeReturnedWithTheEventsLoaded()
        {
            Guid   id           = _fixture.Create <Guid>();
            string mockProperty = _fixture.Create <string>();
            IEvent e            = new MockPropertyChangedEvent(id, mockProperty)
            {
                Version = 1
            };

            _mockEventStore.Setup(call => call.Fetch(id)).Returns(Task.FromResult <IEnumerable <IEvent> >(new[] { e }));

            MockAggregator actualAggregator = _repository.FetchAsync(id).Result;

            actualAggregator.Id.Should().Be(id);
            actualAggregator.MockProperty.Should().Be(mockProperty);
            actualAggregator.Version.Should().Be(e.Version);
        }