public void CommittedEvent_WithUpgradableEvent_GetsUpgrades()
        {
            var aggregateEventUpcaster  = new TestAggregateEventUpcaster();
            var aggregateSequenceNumber = 3;
            var aggregateId             = TestAggregateId.New;
            var aggregateEvent          = new TestCreatedEvent(aggregateId);
            var now     = DateTimeOffset.UtcNow;
            var eventId = EventId.NewDeterministic(
                GuidFactories.Deterministic.Namespaces.Events,
                $"{aggregateId.Value}-v{3}");
            var eventMetadata = new Metadata
            {
                Timestamp = now,
                AggregateSequenceNumber = aggregateSequenceNumber,
                AggregateName           = typeof(TestAggregate).GetAggregateName().Value,
                AggregateId             = aggregateId.Value,
                EventId = eventId
            };
            var committedEvent =
                new CommittedEvent <TestAggregate, TestAggregateId, TestCreatedEvent>(
                    aggregateId,
                    aggregateEvent,
                    eventMetadata,
                    now,
                    aggregateSequenceNumber);

            var eventSequence = aggregateEventUpcaster.FromJournal(committedEvent, string.Empty);
            var upcastedEvent = eventSequence.Events.Single();

            upcastedEvent
            .As <ICommittedEvent <TestAggregate, TestAggregateId, TestCreatedEventV2> >()
            .AggregateEvent.Name
            .Should().Be("default upcasted string");
        }
        public void NonCommittedEvent_WhenRead_IsReturnedUnchanged()
        {
            var message       = new CreateTestCommand(TestAggregateId.New, CommandId.New);
            var eventUpcaster = new TestAggregateEventUpcaster();

            var unchanged = eventUpcaster.FromJournal(message, string.Empty);

            unchanged.Events.Single().As <CreateTestCommand>().GetSourceId().Should().Be(message.GetSourceId());
            unchanged.Events.Single().As <CreateTestCommand>().AggregateId.Should().Be(message.AggregateId);
        }
예제 #3
0
        public void CommittedEvent_Tagged_ContainsTaggedElements()
        {
            var aggregateEventTagger    = new TestAggregateEventUpcaster();
            var aggregateSequenceNumber = 3;
            var aggregateId             = TestAggregateId.New;
            var aggregateEvent          = new TestCreatedEvent(aggregateId);
            var now     = DateTimeOffset.UtcNow;
            var eventId = EventId.NewDeterministic(
                GuidFactories.Deterministic.Namespaces.Events,
                $"{aggregateId.Value}-v{3}");
            var eventMetadata = new Metadata
            {
                Timestamp = now,
                AggregateSequenceNumber = aggregateSequenceNumber,
                AggregateName           = typeof(TestAggregate).GetAggregateName().Value,
                AggregateId             = aggregateId.Value,
                EventId = eventId
            };
            var committedEvent =
                new CommittedEvent <TestAggregate, TestAggregateId, TestCreatedEvent>(
                    aggregateId,
                    aggregateEvent,
                    eventMetadata,
                    now,
                    aggregateSequenceNumber);

            var eventSequence = aggregateEventTagger.FromJournal(committedEvent, string.Empty);
            var upcastedEvent = eventSequence.Events.Single();

            if (upcastedEvent is ICommittedEvent <TestAggregate, TestAggregateId, TestCreatedEventV2> e)
            {
                e.AggregateEvent.GetType().Should().Be <TestCreatedEventV2>();
            }
            else
            {
                false.Should().BeTrue();
            }
        }