Ejemplo n.º 1
0
        public async Task <bool> RestoreDataWithAuditingWhenDoesNotExistButIndexingFails()
        {
            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(true);
            MockIndexer
            .Setup(x => x.Index(ExpectedAuditedEntity))
            .ReturnsAsync(false);
            var result = await DataManager.Restore <AuditedEntity>(ExpectedAuditedEntity.Id);

            MockAudit
            .Verify(x => x.RollbackEvent(ExpectedAuditedEntity), Times.Once);
            MockDataStream
            .Verify(x => x.Delete <AuditedEntity>(ExpectedAuditedEntity.Id), Times.Once);
            return(result);
        }
Ejemplo n.º 2
0
        public async Task <bool> DeleteDataWithAuditCommitEventFails()
        {
            MockAudit
            .Setup(x => x.CommitEvents(ExpectedAuditedEntity))
            .ReturnsAsync(false);
            var result = await DataManager.Delete <AuditedEntity>(ExpectedAuditedEntity.Id);

            MockDataStream
            .Verify(x => x.Rollback(ExpectedAuditedEntity.Id, ExpectedAuditedEntity), Times.Once);
            return(result);
        }
Ejemplo n.º 3
0
        public async Task <bool> DeleteDataWithAuditDeleteEventFails()
        {
            MockAudit
            .Setup(x => x.DeleteEvent(It.IsAny <AuditedEntity>()))
            .ReturnsAsync(false);
            var result = await DataManager.Delete <AuditedEntity>(ExpectedAuditedEntity.Id);

            MockDataStream
            .Verify(x => x.Delete <AuditedEntity>(It.IsAny <int>()), Times.Never);
            return(result);
        }
Ejemplo n.º 4
0
        public async Task <bool> WriteDataWithAuditWhenAuditCommitFails()
        {
            MockAudit
            .Setup(x => x.CommitEvents(ExpectedAuditedEntity))
            .ReturnsAsync(false);
            var result = await DataManager.Write(ExpectedAuditedEntity);

            MockDataStream
            .Verify(x => x.Rollback(ExpectedAuditedEntity.Id, ExpectedAuditedEntity), Times.Once);
            MockIndexer
            .Verify(x => x.Index(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CreationEvent(It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }
Ejemplo n.º 5
0
 public async Task <bool> RestoreDataWithAuditingWhenDoesNotExistAndRestoredSuccessfully()
 {
     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(true);
     MockIndexer
     .Setup(x => x.Index(ExpectedAuditedEntity))
     .ReturnsAsync(true);
     return(await DataManager.Restore <AuditedEntity>(ExpectedAuditedEntity.Id));
 }
Ejemplo n.º 6
0
        public async Task <bool> RestoreDataWhenDoesNotExistRestoredSuccessfully()
        {
            MockDataStream
            .SetupSequence(x => x.Exists <BasicEntity>(ExpectedBasicEntity1.Id))
            .ReturnsAsync(false)
            .ReturnsAsync(true);
            MockDataStream
            .Setup(x => x.Undelete <BasicEntity>(ExpectedBasicEntity1.Id))
            .ReturnsAsync(true);
            MockAudit
            .Setup(x => x.UndeleteEvent(ExpectedBasicEntity1))
            .ReturnsAsync(true);
            MockIndexer
            .Setup(x => x.Index(ExpectedBasicEntity1))
            .ReturnsAsync(true);
            var result = await DataManager.Restore <BasicEntity>(ExpectedBasicEntity1.Id);

            MockDataStream
            .Verify(x => x.Delete <BasicEntity>(ExpectedBasicEntity1.Id), Times.Never);
            return(result);
        }
Ejemplo n.º 7
0
        public async Task <bool> WriteDataWithAuditUpdateEventFails()
        {
            MockAudit
            .Setup(x => x.UpdateEvent(ExpectedAuditedEntity, ExpectedAuditedEntity))
            .ReturnsAsync(false);
            var result = await DataManager.Write(ExpectedAuditedEntity);

            MockDataStream
            .Verify(x => x.DiscardChanges <BasicEntity>(ExpectedAuditedEntity.Id));
            MockDataStream
            .Verify(x => x.Commit <BasicEntity>(It.IsAny <int>()), Times.Never);
            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.CreationEvent(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CommitEvents(It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }