Beispiel #1
0
        public void AggregateEventTagger_TaggingNonEvent_ShouldBeLeftAlone()
        {
            var aggregateEventTagger = new AggregateEventTagger();
            var command = new CreateTestCommand(TestAggregateId.New, CommandId.New);

            var untagged = aggregateEventTagger.ToJournal(command);

            command.Should().Be(untagged);
        }
Beispiel #2
0
        public void CommittedEvent_WhenTagged_ContainsAggregateEventAsTaggedElement()
        {
            var aggregateEventTagger    = new AggregateEventTagger();
            var aggregateSequenceNumber = 3;
            var aggregateId             = TestAggregateId.New;
            var entityId       = TestId.New;
            var entity         = new Test(entityId);
            var aggregateEvent = new TestAddedEvent(entity);
            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, TestAddedEvent>(
                    aggregateId,
                    aggregateEvent,
                    eventMetadata,
                    now,
                    aggregateSequenceNumber);

            var taggedEvent = aggregateEventTagger.ToJournal(committedEvent);

            if (taggedEvent is Tagged a)
            {
                a.Tags.Should().Contain("TestAdded");
            }
            else
            {
                false.Should().BeTrue();
            }
        }