V10: fix build warnings in test projects (#12509)
* Run code cleanup * Dotnet format benchmarks project * Fix up Test.Common * Run dotnet format + manual cleanup * Run code cleanup for unit tests * Run dotnet format * Fix up errors * Manual cleanup of Unit test project * Update tests/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/TestDbMeta.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Benchmarks/TypeFinderBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Umbraco.Core/Events/EventAggregatorTests.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix according to review * Fix after merge * Fix errors Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
@@ -12,136 +12,125 @@ using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Infrastructure.HostedServices;
|
||||
using Umbraco.Cms.Tests.UnitTests.AutoFixture;
|
||||
|
||||
namespace Umbraco.Tests.Scheduling
|
||||
namespace Umbraco.Tests.Scheduling;
|
||||
|
||||
[TestFixture]
|
||||
internal class ContentVersionCleanupTest
|
||||
{
|
||||
[TestFixture]
|
||||
class ContentVersionCleanupTest
|
||||
[Test]
|
||||
[AutoMoqData]
|
||||
public async Task ContentVersionCleanup_WhenNotEnabled_DoesNotCleanupWillRepeat(
|
||||
[Frozen] Mock<IOptionsMonitor<ContentSettings>> settings,
|
||||
[Frozen] Mock<IMainDom> mainDom,
|
||||
[Frozen] Mock<IServerRoleAccessor> serverRoleAccessor,
|
||||
[Frozen] Mock<IRuntimeState> runtimeState,
|
||||
[Frozen] Mock<IContentVersionService> cleanupService,
|
||||
ContentVersionCleanup sut)
|
||||
{
|
||||
[Test, AutoMoqData]
|
||||
public async Task ContentVersionCleanup_WhenNotEnabled_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
|
||||
{
|
||||
settings.Setup(x => x.CurrentValue).Returns(new ContentSettings()
|
||||
{
|
||||
ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings()
|
||||
{
|
||||
EnableCleanup = false
|
||||
}
|
||||
});
|
||||
runtimeState.Setup(x => x.Level).Returns(RuntimeLevel.Run);
|
||||
mainDom.Setup(x => x.IsMainDom).Returns(true);
|
||||
serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.SchedulingPublisher);
|
||||
ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings { EnableCleanup = false },
|
||||
});
|
||||
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);
|
||||
await sut.PerformExecuteAsync(null);
|
||||
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test, AutoMoqData]
|
||||
public async Task ContentVersionCleanup_RuntimeLevelNotRun_DoesNotCleanupWillRepeat(
|
||||
[Frozen] Mock<IOptionsMonitor<ContentSettings>> settings,
|
||||
[Frozen] Mock<IMainDom> mainDom,
|
||||
[Frozen] Mock<IServerRoleAccessor> serverRoleAccessor,
|
||||
[Frozen] Mock<IRuntimeState> runtimeState,
|
||||
[Frozen] Mock<IContentVersionService> cleanupService,
|
||||
ContentVersionCleanup sut)
|
||||
[Test]
|
||||
[AutoMoqData]
|
||||
public async Task ContentVersionCleanup_RuntimeLevelNotRun_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
|
||||
{
|
||||
settings.Setup(x => x.CurrentValue).Returns(new ContentSettings()
|
||||
{
|
||||
ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings()
|
||||
{
|
||||
EnableCleanup = true
|
||||
}
|
||||
});
|
||||
runtimeState.Setup(x => x.Level).Returns(RuntimeLevel.Unknown);
|
||||
mainDom.Setup(x => x.IsMainDom).Returns(true);
|
||||
serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.SchedulingPublisher);
|
||||
ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings { EnableCleanup = true },
|
||||
});
|
||||
runtimeState.Setup(x => x.Level).Returns(RuntimeLevel.Unknown);
|
||||
mainDom.Setup(x => x.IsMainDom).Returns(true);
|
||||
serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.SchedulingPublisher);
|
||||
|
||||
await sut.PerformExecuteAsync(null);
|
||||
await sut.PerformExecuteAsync(null);
|
||||
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test, AutoMoqData]
|
||||
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)
|
||||
[Test]
|
||||
[AutoMoqData]
|
||||
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
|
||||
{
|
||||
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);
|
||||
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);
|
||||
await sut.PerformExecuteAsync(null);
|
||||
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test, AutoMoqData]
|
||||
public async Task ContentVersionCleanup_NotMainDom_DoesNotCleanupWillNotRepeat(
|
||||
[Frozen] Mock<IOptionsMonitor<ContentSettings>> settings,
|
||||
[Frozen] Mock<IMainDom> mainDom,
|
||||
[Frozen] Mock<IServerRoleAccessor> serverRoleAccessor,
|
||||
[Frozen] Mock<IRuntimeState> runtimeState,
|
||||
[Frozen] Mock<IContentVersionService> cleanupService,
|
||||
ContentVersionCleanup sut)
|
||||
[Test]
|
||||
[AutoMoqData]
|
||||
public async Task ContentVersionCleanup_NotMainDom_DoesNotCleanupWillNotRepeat(
|
||||
[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
|
||||
{
|
||||
settings.Setup(x => x.CurrentValue).Returns(new ContentSettings()
|
||||
{
|
||||
ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings()
|
||||
{
|
||||
EnableCleanup = true
|
||||
}
|
||||
});
|
||||
ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings { EnableCleanup = true },
|
||||
});
|
||||
|
||||
runtimeState.Setup(x => x.Level).Returns(RuntimeLevel.Run);
|
||||
mainDom.Setup(x => x.IsMainDom).Returns(false);
|
||||
serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.SchedulingPublisher);
|
||||
runtimeState.Setup(x => x.Level).Returns(RuntimeLevel.Run);
|
||||
mainDom.Setup(x => x.IsMainDom).Returns(false);
|
||||
serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.SchedulingPublisher);
|
||||
|
||||
await sut.PerformExecuteAsync(null);
|
||||
await sut.PerformExecuteAsync(null);
|
||||
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test, AutoMoqData]
|
||||
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)
|
||||
[Test]
|
||||
[AutoMoqData]
|
||||
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
|
||||
{
|
||||
settings.Setup(x => x.CurrentValue).Returns(new ContentSettings()
|
||||
{
|
||||
ContentVersionCleanupPolicy = new ContentVersionCleanupPolicySettings()
|
||||
{
|
||||
EnableCleanup = true
|
||||
}
|
||||
});
|
||||
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);
|
||||
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);
|
||||
await sut.PerformExecuteAsync(null);
|
||||
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Once);
|
||||
}
|
||||
cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny<DateTime>()), Times.Once);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user