示例#1
0
        public void GetRowKey_returns_prefixed_correlation_id()
        {
            var    correlationId = Guid.NewGuid();
            string actual        = Correlation.GetRowKey(correlationId);

            actual.Should().Be($"Correlation-{correlationId:n}");
        }
        public async Task SaveEvents_does_not_insert_pending_event_entities_if_fails_to_insert_correlation_entities()
        {
            // Arrange
            var fixture = new Fixture();
            var user    = new FakeUser(Guid.NewGuid(), fixture.Create <string>());

            user.ChangeUsername(fixture.Create <string>());
            IList <IDomainEvent> domainEvents = user.FlushPendingEvents().ToList();
            var correlationId = Guid.NewGuid();

            var batch = new TableBatchOperation();

            batch.Insert(new TableEntity
            {
                PartitionKey = AggregateEntity.GetPartitionKey(typeof(FakeUser), user.Id),
                RowKey       = Correlation.GetRowKey(correlationId),
            });
            await s_eventTable.ExecuteBatchAsync(batch);

            // Act
            Func <Task> action = () => _sut.SaveEvents <FakeUser>(domainEvents, correlationId: correlationId);

            // Assert
            action.ShouldThrow <DuplicateCorrelationException>();
            string filter = PendingEvent.GetFilter(typeof(FakeUser), user.Id);
            var    query  = new TableQuery <PendingEvent> {
                FilterString = filter
            };
            IEnumerable <PendingEvent> actual = await s_eventTable.ExecuteQuerySegmentedAsync(query, default);

            actual.Should().BeEmpty();
        }
示例#3
0
        public void Create_sets_RowKey_correctly()
        {
            Type sourceType    = new Fixture().Create <Type>();
            var  sourceId      = Guid.NewGuid();
            var  correlationId = Guid.NewGuid();

            var actual = Correlation.Create(sourceType, sourceId, correlationId);

            actual.RowKey.Should().Be(Correlation.GetRowKey(correlationId));
        }