diff --git a/tests/Umbraco.TestData/Configuration/TestDataSettings.cs b/tests/Umbraco.TestData/Configuration/TestDataSettings.cs
index 78084f726a..687a696bcc 100644
--- a/tests/Umbraco.TestData/Configuration/TestDataSettings.cs
+++ b/tests/Umbraco.TestData/Configuration/TestDataSettings.cs
@@ -1,16 +1,15 @@
-namespace Umbraco.TestData.Configuration
-{
- public class TestDataSettings
- {
- ///
- /// Gets or sets a value indicating whether the test data generation is enabled.
- ///
- public bool Enabled { get; set; } = false;
+namespace Umbraco.TestData.Configuration;
- ///
- /// Gets or sets a value indicating whether persisted local database cache files for content and media are disabled.
- ///
- /// The URL path.
- public bool IgnoreLocalDb { get; set; } = false;
- }
+public class TestDataSettings
+{
+ ///
+ /// Gets or sets a value indicating whether the test data generation is enabled.
+ ///
+ public bool Enabled { get; set; } = false;
+
+ ///
+ /// Gets or sets a value indicating whether persisted local database cache files for content and media are disabled.
+ ///
+ /// The URL path.
+ public bool IgnoreLocalDb { get; set; } = false;
}
diff --git a/tests/Umbraco.TestData/Extensions/UmbracoBuilderExtensions.cs b/tests/Umbraco.TestData/Extensions/UmbracoBuilderExtensions.cs
index 7e3e2a70b1..c695653503 100644
--- a/tests/Umbraco.TestData/Extensions/UmbracoBuilderExtensions.cs
+++ b/tests/Umbraco.TestData/Extensions/UmbracoBuilderExtensions.cs
@@ -7,48 +7,44 @@ using Umbraco.Cms.Infrastructure.PublishedCache;
using Umbraco.Cms.Web.Common.ApplicationBuilder;
using Umbraco.TestData.Configuration;
-namespace Umbraco.TestData.Extensions
+namespace Umbraco.TestData.Extensions;
+
+public static class UmbracoBuilderExtensions
{
- public static class UmbracoBuilderExtensions
+ public static IUmbracoBuilder AddUmbracoTestData(this IUmbracoBuilder builder)
{
- public static IUmbracoBuilder AddUmbracoTestData(this IUmbracoBuilder builder)
+ if (builder.Services.Any(x => x.ServiceType == typeof(LoadTestController)))
{
- if (builder.Services.Any(x => x.ServiceType == typeof(LoadTestController)))
- {
- // We assume the test data project is composed if any implementations of LoadTestController exist.
- return builder;
- }
-
- IConfigurationSection testDataSection = builder.Config.GetSection("Umbraco:CMS:TestData");
- TestDataSettings config = testDataSection.Get();
- if (config == null || config.Enabled == false)
- {
- return builder;
- }
-
- builder.Services.Configure(testDataSection);
-
- if (config.IgnoreLocalDb)
- {
- builder.Services.AddSingleton(factory => new PublishedSnapshotServiceOptions
- {
- IgnoreLocalDb = true
- });
- }
-
- builder.Services.Configure(options =>
- options.AddFilter(new UmbracoPipelineFilter(nameof(LoadTestController))
- {
- Endpoints = app => app.UseEndpoints(endpoints =>
- endpoints.MapControllerRoute(
- "LoadTest",
- "/LoadTest/{action}",
- new { controller = "LoadTest", Action = "Index" }))
- }));
-
- builder.Services.AddScoped(typeof(LoadTestController));
-
+ // We assume the test data project is composed if any implementations of LoadTestController exist.
return builder;
}
+
+ var testDataSection = builder.Config.GetSection("Umbraco:CMS:TestData");
+ var config = testDataSection.Get();
+ if (config == null || config.Enabled == false)
+ {
+ return builder;
+ }
+
+ builder.Services.Configure(testDataSection);
+
+ if (config.IgnoreLocalDb)
+ {
+ builder.Services.AddSingleton(factory => new PublishedSnapshotServiceOptions { IgnoreLocalDb = true });
+ }
+
+ builder.Services.Configure(options =>
+ options.AddFilter(new UmbracoPipelineFilter(nameof(LoadTestController))
+ {
+ Endpoints = app => app.UseEndpoints(endpoints =>
+ endpoints.MapControllerRoute(
+ "LoadTest",
+ "/LoadTest/{action}",
+ new { controller = "LoadTest", Action = "Index" }))
+ }));
+
+ builder.Services.AddScoped(typeof(LoadTestController));
+
+ return builder;
}
}
diff --git a/tests/Umbraco.TestData/LoadTestComposer.cs b/tests/Umbraco.TestData/LoadTestComposer.cs
index 3d3302b881..f44d8edfb2 100644
--- a/tests/Umbraco.TestData/LoadTestComposer.cs
+++ b/tests/Umbraco.TestData/LoadTestComposer.cs
@@ -4,10 +4,9 @@ using Umbraco.TestData.Extensions;
// see https://github.com/Shazwazza/UmbracoScripts/tree/master/src/LoadTesting
-namespace Umbraco.TestData
+namespace Umbraco.TestData;
+
+public class LoadTestComposer : IComposer
{
- public class LoadTestComposer : IComposer
- {
- public void Compose(IUmbracoBuilder builder) => builder.AddUmbracoTestData();
- }
+ public void Compose(IUmbracoBuilder builder) => builder.AddUmbracoTestData();
}
diff --git a/tests/Umbraco.TestData/LoadTestController.cs b/tests/Umbraco.TestData/LoadTestController.cs
index c245aae816..741fe4e94b 100644
--- a/tests/Umbraco.TestData/LoadTestController.cs
+++ b/tests/Umbraco.TestData/LoadTestController.cs
@@ -10,24 +10,28 @@ using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
+using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
// see https://github.com/Shazwazza/UmbracoScripts/tree/master/src/LoadTesting
-namespace Umbraco.TestData
+namespace Umbraco.TestData;
+
+public class LoadTestController : Controller
{
- public class LoadTestController : Controller
- {
- private static readonly Random s_random = new Random();
- private static readonly object s_locko = new object();
+ private const string ContainerAlias = "LoadTestContainer";
+ private const string ContentAlias = "LoadTestContent";
+ private const int TextboxDefinitionId = -88;
+ private const int MaxCreate = 1000;
- private static volatile int s_containerId = -1;
+ private const string FootHtml = @"