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); }
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)); }
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); }