Esempio n. 1
0
        public async Task <bool> WriteNewDataWithAuditCommitFails()
        {
            MockDataStream
            .Setup(x => x.Commit <BasicEntity>(ExpectedAuditedEntity.Id))
            .ReturnsAsync(false);
            MockDataStream
            .Setup(x => x.Exists <AuditedEntity>(ExpectedAuditedEntity.Id))
            .ReturnsAsync(false);
            var result = await DataManager.Write(ExpectedAuditedEntity);

            MockAudit
            .Verify(x => x.DiscardEvents(ExpectedAuditedEntity));
            MockDataStream
            .Verify(x => x.Rollback(It.IsAny <int>(), It.IsAny <DataEntity>()), Times.Never);
            MockIndexer
            .Verify(x => x.Index(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.UpdateEvent(It.IsAny <DataEntity>(), It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CommitEvents(It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }
Esempio n. 2
0
        public async Task <bool> RestoreDataWithAuditingWhenDoesNotExistButCommitEventFails()
        {
            MockDataStream
            .SetupSequence(x => x.Exists <AuditedEntity>(ExpectedAuditedEntity.Id))
            .ReturnsAsync(false)
            .ReturnsAsync(true);
            MockDataStream
            .Setup(x => x.Undelete <AuditedEntity>(ExpectedAuditedEntity.Id))
            .ReturnsAsync(true);
            MockAudit
            .Setup(x => x.UndeleteEvent(ExpectedAuditedEntity))
            .ReturnsAsync(true);
            MockAudit
            .Setup(x => x.CommitEvents(ExpectedAuditedEntity))
            .ReturnsAsync(false);
            var result = await DataManager.Restore <AuditedEntity>(ExpectedAuditedEntity.Id);

            MockAudit
            .Verify(x => x.DiscardEvents(ExpectedAuditedEntity), Times.Once);
            MockDataStream
            .Verify(x => x.Delete <AuditedEntity>(ExpectedAuditedEntity.Id), Times.Once);
            return(result);
        }