public void ContentVersionCleanup_NotMainDom_DoesNotCleanupWillNotRepeat( [Frozen] Mock <IContentVersionCleanupPolicyGlobalSettings> settings, [Frozen] Mock <IRuntimeState> state, [Frozen] Mock <IContentVersionService> cleanupService, ContentVersionCleanup sut) { settings.Setup(x => x.EnableCleanup).Returns(true); state.Setup(x => x.Level).Returns(RuntimeLevel.Run); state.Setup(x => x.IsMainDom).Returns(false); state.Setup(x => x.ServerRole).Returns(ServerRole.Master); var result = sut.PerformRun(); Assert.Multiple(() => { Assert.False(result); cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny <DateTime>()), Times.Never); }); }
public async Task ContentVersionCleanup_ServerRoleUnknown_DoesNotCleanupWillRepeat( [Frozen] Mock <IOptionsMonitor <ContentSettings> > settings, [Frozen] Mock <IMainDom> mainDom, [Frozen] Mock <IServerRoleAccessor> serverRoleAccessor, [Frozen] Mock <IRuntimeState> runtimeState, [Frozen] Mock <IContentVersionService> cleanupService, ContentVersionCleanup sut) { settings.Setup(x => x.CurrentValue).Returns(new ContentSettings { ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings { EnableCleanup = true }, }); runtimeState.Setup(x => x.Level).Returns(RuntimeLevel.Run); mainDom.Setup(x => x.IsMainDom).Returns(true); serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.Unknown); await sut.PerformExecuteAsync(null); cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny <DateTime>()), Times.Never); }
public async Task ContentVersionCleanup_Enabled_DelegatesToCleanupService( [Frozen] Mock <IOptionsMonitor <ContentSettings> > settings, [Frozen] Mock <IMainDom> mainDom, [Frozen] Mock <IServerRoleAccessor> serverRoleAccessor, [Frozen] Mock <IRuntimeState> runtimeState, [Frozen] Mock <IContentVersionService> cleanupService, ContentVersionCleanup sut) { settings.Setup(x => x.CurrentValue).Returns(new ContentSettings() { ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings() { EnableCleanup = true } }); runtimeState.Setup(x => x.Level).Returns(RuntimeLevel.Run); mainDom.Setup(x => x.IsMainDom).Returns(true); serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.SchedulingPublisher); await sut.PerformExecuteAsync(null); cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny <DateTime>()), Times.Once); }