Formats code comments as sentences in the tests.

Capitalizes the first word and adds the terminal period in the unit, integration and security tests. The AAA markers stay bare, the TODO bodies stay lowercase, and no assertion, payload, expected status code or test signature changes.
This commit is contained in:
BinaryAlley committed 2026-11-16 18:17:29 +02:00
1 parent 727aa33318
commit 057f557791
540 files changed
+3888 -3888

No files matched your search

@@ -40,7 +40,7 @@ public class LoginUserQueryFixture
.RuleFor(x => x.Password, resolvedPassword);
if (shouldIncludeTotpCode)
faker.RuleFor(x => x.TotpCode, f => totpCode ?? f.Random.Replace("######")); // generates 6 random digits when no code is pinned
faker.RuleFor(x => x.TotpCode, f => totpCode ?? f.Random.Replace("######")); // Generates 6 random digits when no code is pinned.
return faker.Generate();
}
@@ -43,7 +43,7 @@ public class MediaContributorDtoFixture
displayName: displayName,
legalName: legalName,
includeDisplayName: includeDisplayName,
// this fixture historically left the legal name null unless one was explicitly supplied, so the name fixture is only asked for one when a value is passed
// This fixture historically left the legal name null unless one was explicitly supplied, so the name fixture is only asked for one when a value is passed.
includeLegalName: includeLegalName && legalName is not null) : null,
Role: includeRole ? role ?? _faker.PickRandom<MediaContributorRole>() : null);
}
@@ -26,7 +26,7 @@ public class ThumbnailFixture
public Thumbnail Create(ImageType? type = null, byte[]? bytes = null)
{
type ??= _faker.PickRandom<ImageType>();
bytes ??= _faker.Random.Bytes(1024); // Generate 1KB of random bytes
bytes ??= _faker.Random.Bytes(1024); // Generate 1KB of random bytes.
return new Thumbnail(type.Value, bytes);
}
@@ -19,7 +19,7 @@ public class QRCodeGeneratorFixture
public static (string Username, byte[] Secret) CreateQrCodeTestData()
{
string username = new Faker().Person.UserName;
byte[] secret = new byte[20]; // Standard TOTP secret length
byte[] secret = new byte[20]; // Standard TOTP secret length.
Random.Shared.NextBytes(secret);
return (username, secret);
}
@@ -25,7 +25,7 @@ public class CryptographyServiceFixture
/// <returns>The configured options.</returns>
public IOptions<EncryptionSettingsDto> CreateEncryptionSettings()
{
// Generate a valid 256-bit (32 byte) key for AES-256
// Generate a valid 256-bit (32 byte) key for AES-256.
byte[] key = new byte[32];
RandomNumberGenerator.Fill(key);
string base64Key = Convert.ToBase64String(key);
@@ -38,25 +38,25 @@ public class FileSystemStructureFixture
/// <returns>The path to the root directory of the created file system structure.</returns>
public string CreateFileSystemStructure()
{
// create the root directory
// Create the root directory.
Directory.CreateDirectory(_rootPath);
string currentPath = _rootPath;
for (int i = 1; i <= 3; i++)
{
// create a nested subdirectory
// Create a nested subdirectory.
currentPath = Path.Combine(currentPath, $"NestedDirectory_{i}");
Directory.CreateDirectory(currentPath);
// create two text files in the current directory
// Create two text files in the current directory.
for (int j = 1; j <= 2; j++)
{
string filePath = Path.Combine(currentPath, $"TestFile_{j}.txt");
File.WriteAllText(filePath, _faker.Lorem.Paragraph());
// make the first file in each directory hidden
// Make the first file in each directory hidden.
if (j == 1)
SetHidden(filePath);
}
// make the second nested directory hidden
// Make the second nested directory hidden.
if (i == 2)
currentPath = SetHidden(currentPath);
}
@@ -69,10 +69,10 @@ public class FileSystemStructureFixture
/// <returns><see langword="true"/> when hidden elements can be created, otherwise <see langword="false"/>.</returns>
private static bool DetectHiddenAttributeSupport()
{
// on Unix-like systems the fixture hides elements with the dot-prefix convention, which the file system always supports
// On Unix-like systems the fixture hides elements with the dot-prefix convention, which the file system always supports.
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
return true;
// on Windows the fixture relies on the hidden file attribute, which some file systems (for example network drives) do not persist
// On Windows the fixture relies on the hidden file attribute, which some file systems (for example network drives) do not persist.
string probePath = Path.Combine(AppContext.BaseDirectory, "lumina_hidden_attribute_probe_" + Guid.NewGuid());
try
{
@@ -111,7 +111,7 @@ public class FileSystemStructureFixture
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
{
// On Unix-like systems, rename the file/directory to start with a dot
// On Unix-like systems, rename the file/directory to start with a dot.
string directory = Path.GetDirectoryName(path)!;
string name = Path.GetFileName(path);
string newPath = Path.Combine(directory, "." + name);
@@ -29,9 +29,9 @@ public static class TestHttpContextFactory
public static DefaultHttpContext Create(string? culture = "en-US", ClaimsPrincipal? user = null, ISession? session = null)
{
DefaultHttpContext httpContext = new();
// provide a writable response body, so that executed IResult instances can be inspected by the tests
// Provide a writable response body, so that executed IResult instances can be inspected by the tests.
httpContext.Features.Set<IHttpResponseBodyFeature>(new StreamResponseBodyFeature(new MemoryStream()));
// provide the minimal services needed by the result execution machinery (logging, options, JSON options)
// Provide the minimal services needed by the result execution machinery (logging, options, JSON options).
httpContext.RequestServices = CreateServiceProvider();
httpContext.Request.RouteValues["culture"] = culture;
if (user is not null)
@@ -91,7 +91,7 @@ public static class TestHttpContextFactory
public static ISession CreateSession()
{
ISession session = Substitute.For<ISession>();
#pragma warning disable CS8601 // possible null reference assignment in the NSubstitute out-argument stub
#pragma warning disable CS8601 // Possible null reference assignment in the NSubstitute out-argument stub.
session.TryGetValue(Arg.Any<string>(), out Arg.Any<byte[]>()).Returns(callInfo =>
{
callInfo[1] = null;
@@ -32,7 +32,7 @@ public static partial class WebTestHelpers
private const string LOGIN_PAGE_PATH = "/en-us/auth/login";
private const string LOGIN_ENDPOINT_PATH = "/en-us/auth/api-login";
// the change password page renders an antiforgery token for the authenticated user without calling the remote API
// The change password page renders an antiforgery token for the authenticated user without calling the remote API.
private const string AUTHENTICATED_TOKEN_PAGE_PATH = "/en-us/auth/change-password";
[GeneratedRegex("name=\"__RequestVerificationToken\"[^>]*value=\"([^\"]*)\"")]
@@ -57,7 +57,7 @@ public static partial class WebTestHelpers
/// <returns>An HTTP client authenticated with the application's authentication cookie, together with an antiforgery token.</returns>
public static async Task<AuthenticatedWebClient> CreateAuthenticatedClientAsync(WebApplicationFactory<Program> factory, string? username = "testuser", string? password = "TestPass123!")
{
// the application marks its cookies as secure, so the test client must communicate over HTTPS for the cookies to be sent back
// The application marks its cookies as secure, so the test client must communicate over HTTPS for the cookies to be sent back.
HttpClient client = factory.CreateClient(new WebApplicationFactoryClientOptions
{
BaseAddress = new Uri("https://localhost"),
@@ -65,9 +65,9 @@ public static partial class WebTestHelpers
});
string antiforgeryToken = await GetAntiforgeryTokenAsync(client);
await LoginAsync(client, username!, password!, antiforgeryToken);
// the antiforgery token is bound to the authenticated user, because the antiforgery middleware runs after
// The antiforgery token is bound to the authenticated user, because the antiforgery middleware runs after
// authentication; the token captured from the anonymous login page is rejected with a 400 for authenticated
// mutating requests, so a fresh token must be captured after the login
// mutating requests, so a fresh token must be captured after the login.
string authenticatedAntiforgeryToken = await GetAntiforgeryTokenAsync(client, AUTHENTICATED_TOKEN_PAGE_PATH);
return new AuthenticatedWebClient(client, authenticatedAntiforgeryToken);
}