protected async Task <(IAllowSync, IDeleteGraphSyncer?)> GetDeleteGraphSyncerIfDeleteAllowed( ContentItem contentItem, IContentItemVersion contentItemVersion, SyncOperation syncOperation) { try { IDeleteGraphSyncer deleteGraphSyncer = _serviceProvider.GetRequiredService <IDeleteGraphSyncer>(); IAllowSync allowSync = await deleteGraphSyncer.DeleteAllowed( contentItem, contentItemVersion, syncOperation); return(allowSync, deleteGraphSyncer); } catch (Exception exception) { string contentType = GetContentTypeDisplayName(contentItem); //todo: will get logged twice, but want to keep the param version _logger.LogError(exception, "Unable to check if the '{ContentItem}' {ContentType} can be {DeleteOperation} from the {GraphReplicaSetName} graph.", contentItem.DisplayText, contentType, syncOperation.ToString("PrP", null).ToLower(), contentItemVersion.GraphReplicaSetName); await _notifier.Add(GetSyncOperationCancelledUserMessage(syncOperation, contentItem.DisplayText, contentType), $"Unable to check if the '{contentItem.DisplayText}' {contentType} can be {syncOperation.ToString("PrP", null).ToLower()} from the {contentItemVersion.GraphReplicaSetName} graph.", exception : exception); throw; } }
public SyncOrchestrator_RestoreTests() { SyncOperation = SyncOperation.Restore; PublishedDeleteGraphSyncer = A.Fake <IDeleteGraphSyncer>(); A.CallTo(() => PublishedDeleteGraphSyncer.DeleteAllowed( A <ContentItem> ._, A <IContentItemVersion> .That.Matches(v => v.GraphReplicaSetName == GraphReplicaSetNames.Published), SyncOperation, null, null)) .Returns(PublishedAllowSync); A.CallTo(() => ServiceProvider.GetService(A <Type> .That.Matches( t => t.Name == (nameof(IMergeGraphSyncer))))) .Returns(PreviewMergeGraphSyncer); A.CallTo(() => ServiceProvider.GetService(A <Type> .That.Matches( t => t.Name == (nameof(IDeleteGraphSyncer))))) .Returns(PublishedDeleteGraphSyncer); }