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

@@ -65,8 +65,8 @@ public class MusicBrainzHttpClientTests
}
[Theory]
[InlineData("https://musicbrainz.org/ws/2/")] // the real service
[InlineData("https://mirror.musicbrainz.org/ws/2/")] // a subdomain of the real service
[InlineData("https://musicbrainz.org/ws/2/")] // The real service.
[InlineData("https://mirror.musicbrainz.org/ws/2/")] // A subdomain of the real service.
public async Task GetRecordingAsync_WhenTheBaseUrlIsTheRealService_ShouldThrottleTheRequests(string baseUrl)
{
// Arrange
@@ -288,9 +288,9 @@ public class MusicBrainzHttpClientTests
}
[Theory]
[InlineData(0, "limit=1")] // a limit below the minimum is clamped up
[InlineData(200, "limit=100")] // a limit above the maximum is clamped down
[InlineData(50, "limit=50")] // a limit within the range is kept
[InlineData(0, "limit=1")] // A limit below the minimum is clamped up.
[InlineData(200, "limit=100")] // A limit above the maximum is clamped down.
[InlineData(50, "limit=50")] // A limit within the range is kept.
public async Task SearchArtistsAsync_WhenTheLimitIsOutOfRange_ShouldClampIt(int requestedLimit, string expectedQuery)
{
// Arrange
@@ -505,11 +505,11 @@ public class MusicBrainzHttpClientTests
}
[Theory]
[InlineData("A & B")] // ampersand query separator
[InlineData("Title #fragment")] // fragment separator
[InlineData("A?B")] // query separator
[InlineData("../../secret")] // path traversal
[InlineData("A\" OR \"B")] // quote escape
[InlineData("A & B")] // Ampersand query separator.
[InlineData("Title #fragment")] // Fragment separator.
[InlineData("A?B")] // Query separator.
[InlineData("../../secret")] // Path traversal.
[InlineData("A\" OR \"B")] // Quote escape.
public async Task SearchArtistsAsync_WhenTheQueryContainsReservedCharacters_ShouldKeepThemInsideTheQueryString(string searchTerm)
{
// Arrange
@@ -189,13 +189,13 @@ public class MusicBrainzMapperTests
}
[Theory]
[InlineData("person", MusicArtistType.Person)] // an individual
[InlineData("group", MusicArtistType.Group)] // an ensemble
[InlineData("orchestra", MusicArtistType.Orchestra)] // an instrumental ensemble
[InlineData("choir", MusicArtistType.Choir)] // a vocal ensemble
[InlineData("character", MusicArtistType.Character)] // a fictional character
[InlineData("other", MusicArtistType.Other)] // a known but uncategorized type
[InlineData("PERSON", MusicArtistType.Person)] // the value is normalized
[InlineData("person", MusicArtistType.Person)] // An individual.
[InlineData("group", MusicArtistType.Group)] // An ensemble.
[InlineData("orchestra", MusicArtistType.Orchestra)] // An instrumental ensemble.
[InlineData("choir", MusicArtistType.Choir)] // A vocal ensemble.
[InlineData("character", MusicArtistType.Character)] // A fictional character.
[InlineData("other", MusicArtistType.Other)] // A known but uncategorized type.
[InlineData("PERSON", MusicArtistType.Person)] // The value is normalized.
public void MapArtist_WhenTheTypeIsKnown_ShouldMapIt(string type, MusicArtistType expected)
{
// Arrange
@@ -227,7 +227,7 @@ public class MusicBrainzMapperTests
[InlineData("female", MusicArtistGender.Female)]
[InlineData("other", MusicArtistGender.Other)]
[InlineData("not applicable", MusicArtistGender.NotApplicable)]
[InlineData("FEMALE", MusicArtistGender.Female)] // the value is normalized
[InlineData("FEMALE", MusicArtistGender.Female)] // The value is normalized.
public void MapArtist_WhenTheGenderIsKnown_ShouldMapIt(string gender, MusicArtistGender expected)
{
// Act
@@ -251,7 +251,7 @@ public class MusicBrainzMapperTests
}
[Theory]
[InlineData("executive producer", MediaContributorRole.ExecutiveProducer)] // more specific than producer
[InlineData("executive producer", MediaContributorRole.ExecutiveProducer)] // More specific than producer.
[InlineData("producer", MediaContributorRole.Producer)]
[InlineData("remixer", MediaContributorRole.Remixer)]
[InlineData("mix", MediaContributorRole.Mixer)]
@@ -703,13 +703,13 @@ public class MusicBrainzMapperTests
}
[Theory]
[InlineData("1975-11-21", 1975, 11, 21, 1975)] // an exact date is parsed fully
[InlineData("1975", null, 0, 0, 1975)] // a bare year yields only the year
[InlineData("Spring 1975", null, 0, 0, 1975)] // an embedded year is extracted when the value is not a date
[InlineData("not a date", null, 0, 0, null)] // an unparsable value yields nothing
[InlineData("2200", null, 0, 0, null)] // a year outside the accepted window yields nothing
[InlineData("2100", null, 0, 0, 2100)] // the upper boundary is accepted
[InlineData(" 1975-11-21 ", 1975, 11, 21, 1975)] // surrounding white space is trimmed
[InlineData("1975-11-21", 1975, 11, 21, 1975)] // An exact date is parsed fully.
[InlineData("1975", null, 0, 0, 1975)] // A bare year yields only the year.
[InlineData("Spring 1975", null, 0, 0, 1975)] // An embedded year is extracted when the value is not a date.
[InlineData("not a date", null, 0, 0, null)] // An unparsable value yields nothing.
[InlineData("2200", null, 0, 0, null)] // A year outside the accepted window yields nothing.
[InlineData("2100", null, 0, 0, 2100)] // The upper boundary is accepted.
[InlineData(" 1975-11-21 ", 1975, 11, 21, 1975)] // Surrounding white space is trimmed.
public void MapAlbum_WhenTheFirstReleaseDateHasVariousShapes_ShouldParseIt(string firstReleaseDate, int? expectedYear, int expectedMonth, int expectedDay, int? expectedParsedYear)
{
// Arrange
@@ -729,10 +729,10 @@ public class MusicBrainzMapperTests
[Theory]
[InlineData("US", ReleaseCountry.US)]
[InlineData("us", ReleaseCountry.US)] // the code is matched case insensitively
[InlineData("XE", ReleaseCountry.XE)] // the Europe special code
[InlineData("XW", ReleaseCountry.XW)] // the Worldwide special code
[InlineData("AN", ReleaseCountry.AN)] // the Netherlands Antilles special code
[InlineData("us", ReleaseCountry.US)] // The code is matched case insensitively.
[InlineData("XE", ReleaseCountry.XE)] // The Europe special code.
[InlineData("XW", ReleaseCountry.XW)] // The Worldwide special code.
[InlineData("AN", ReleaseCountry.AN)] // The Netherlands Antilles special code.
public void MapAlbum_WhenTheReleaseCountryIsKnown_ShouldMapIt(string country, ReleaseCountry expected)
{
// Arrange
@@ -747,9 +747,9 @@ public class MusicBrainzMapperTests
}
[Theory]
[InlineData("ZZ")] // a valid shape but not a known code
[InlineData("")] // an empty value
[InlineData(" ")] // only white space
[InlineData("ZZ")] // A valid shape but not a known code.
[InlineData("")] // An empty value.
[InlineData(" ")] // Only white space.
public void MapAlbum_WhenTheReleaseCountryIsUnknown_ShouldReturnNullCountry(string country)
{
// Arrange
@@ -863,7 +863,7 @@ public class MusicBrainzMapperTests
[InlineData("8cm cd", MusicMediaFormat.Cm8CD)]
[InlineData("dat", MusicMediaFormat.DAT)]
[InlineData("other", MusicMediaFormat.Other)]
[InlineData("made-up", MusicMediaFormat.Other)] // an unknown format still maps to Other
[InlineData("made-up", MusicMediaFormat.Other)] // An unknown format still maps to Other.
public void MapAlbum_WhenTheMediaFormatIsKnownOrUnknownButPresent_ShouldMapIt(string format, MusicMediaFormat expected)
{
// Arrange
@@ -909,7 +909,7 @@ public class MusicBrainzMapperTests
[InlineData("super jewel box", MusicReleasePackaging.SuperJewelBox)]
[InlineData("none", MusicReleasePackaging.None)]
[InlineData("other", MusicReleasePackaging.Other)]
[InlineData("made-up", MusicReleasePackaging.Other)] // an unknown packaging still maps to Other
[InlineData("made-up", MusicReleasePackaging.Other)] // An unknown packaging still maps to Other.
public void MapAlbum_WhenThePackagingIsKnownOrUnknownButPresent_ShouldMapIt(string packaging, MusicReleasePackaging expected)
{
// Arrange
@@ -1051,7 +1051,7 @@ public class MusicBrainzMapperTests
Assert.Null(result.Channels);
Assert.Null(result.BitDepth);
Assert.Null(result.AudioCodec);
Assert.Null(result.Container); // a metadata provider never supplies the container, which is captured locally from the file
Assert.Null(result.Container); // A metadata provider never supplies the container, which is captured locally from the file.
Assert.Null(result.Bitrate);
Assert.Equal(recordingId, result.MusicBrainzRecordingId);
Assert.Null(result.MusicBrainzTrackId);
@@ -1111,10 +1111,10 @@ public class MusicBrainzMapperTests
}
[Theory]
[InlineData(null, null)] // no length at all
[InlineData(0L, null)] // a zero length is treated as unknown
[InlineData(-100L, null)] // a negative length is treated as unknown
[InlineData(1500L, 1)] // milliseconds are truncated to whole seconds
[InlineData(null, null)] // No length at all.
[InlineData(0L, null)] // A zero length is treated as unknown.
[InlineData(-100L, null)] // A negative length is treated as unknown.
[InlineData(1500L, 1)] // Milliseconds are truncated to whole seconds.
[InlineData(215_400L, 215)]
public void MapTrack_WhenTheRecordingHasALength_ShouldMapTheDurationInSeconds(long? length, int? expectedSeconds)
{
@@ -1199,7 +1199,7 @@ public class MusicBrainzMapperTests
}
[Theory]
[InlineData(1.0)] // a value only
[InlineData(1.0)] // A value only.
[InlineData(2.5)]
public void MapArtist_WhenOnlyTheRatingValueIsPresent_ShouldMapItWithANullVoteCount(decimal value)
{
@@ -1262,16 +1262,16 @@ public class MusicBrainzMapperTests
}
[Theory]
[InlineData("eng", "en", "English")] // a three letter code maps to the neutral culture
[InlineData("eng", "en", "English")] // A three letter code maps to the neutral culture.
[InlineData("deu", "de", "German")]
[InlineData("en", "en", "English")] // a two letter code maps too
[InlineData("zxx", "zxx", "No linguistic content")] // a special MusicBrainz code
[InlineData("en", "en", "English")] // A two letter code maps too.
[InlineData("zxx", "zxx", "No linguistic content")] // A special MusicBrainz code.
[InlineData("mul", "mul", "Multiple languages")]
[InlineData("und", "und", "Undetermined")]
[InlineData("eng/ara", "en", "English")] // only the first code of a multi language value is used
[InlineData("/", "/", "/")] // a value with no usable part falls back to the raw code
[InlineData(" eng ", "en", "English")] // surrounding white space is trimmed
[InlineData("qqq", "qqq", "qqq")] // an unknown code falls back to the raw code
[InlineData("eng/ara", "en", "English")] // Only the first code of a multi language value is used.
[InlineData("/", "/", "/")] // A value with no usable part falls back to the raw code.
[InlineData(" eng ", "en", "English")] // Surrounding white space is trimmed.
[InlineData("qqq", "qqq", "qqq")] // An unknown code falls back to the raw code.
public void MapTrack_WhenTheLanguageCodeIsPresent_ShouldMapIt(string language, string expectedCode, string expectedName)
{
// Arrange
@@ -115,7 +115,7 @@ public class MusicBrainzAlbumMetadataProviderTests
Assert.Equal("Other Album", result[1].Title);
Assert.Equal(1, handler.CallCount);
Assert.Contains("limit=10", handler.Requests[0].RequestUri!.Query);
// the quotes are removed from the built query, and the artist constraint is appended
// The quotes are removed from the built query, and the artist constraint is appended.
string query = Uri.UnescapeDataString(handler.Requests[0].RequestUri!.Query);
Assert.Contains("releasegroup:\"The Album\"", query);
Assert.Contains("AND artist:\"The Artist\"", query);
@@ -231,7 +231,7 @@ public class MusicBrainzAlbumMetadataProviderTests
Assert.NotNull(result);
Assert.Equal("The Album", result.Title);
Assert.Equal(s_releaseGroupId, result.MusicBrainzReleaseGroupId);
// the search, the detail lookup and the release browse are all used
// The search, the detail lookup and the release browse are all used.
Assert.Equal(3, handler.CallCount);
Assert.Contains("limit=1", handler.Requests[0].RequestUri!.Query);
}
@@ -461,7 +461,7 @@ public class MusicBrainzAlbumMetadataProviderTests
// Assert
Assert.NotNull(result);
Assert.NotNull(result.CatalogNumbers);
// every distinct catalog number is kept, while the duplicates are removed.
// Every distinct catalog number is kept, while the duplicates are removed.
Assert.Equal(["EMC 4008", "0C 066-98 485"], result.CatalogNumbers);
Assert.Equal("EMI", result.Label);
}
@@ -113,7 +113,7 @@ public class MusicBrainzArtistMetadataProviderTests
Assert.Equal("The Artist", result[0].Name);
Assert.Equal("Other Artist", result[1].Name);
Assert.Equal(1, handler.CallCount);
// the name is trimmed and the configured search result limit is used
// The name is trimmed and the configured search result limit is used.
Assert.Contains("limit=10", handler.Requests[0].RequestUri!.Query);
Assert.Contains("query=The%20Artist", handler.Requests[0].RequestUri!.Query);
}
@@ -227,7 +227,7 @@ public class MusicBrainzArtistMetadataProviderTests
Assert.Equal("The Artist", result.Name);
Assert.Equal(MusicArtistType.Group, result.Type);
Assert.Null(result.MusicBrainzArtistId);
// the search is used, and the per identifier lookup must not be requested
// The search is used, and the per identifier lookup must not be requested.
Assert.Equal(1, handler.CallCount);
}
@@ -89,10 +89,10 @@ public class MusicBrainzSettingsProviderTests
}
[Theory]
[InlineData("not-a-url")] // a value that is not an URI at all
[InlineData("ftp://mirror.example/")] // an absolute URI with an unsupported scheme
[InlineData("relative/path")] // a relative URI
[InlineData(" ")] // only white space
[InlineData("not-a-url")] // A value that is not an URI at all.
[InlineData("ftp://mirror.example/")] // An absolute URI with an unsupported scheme.
[InlineData("relative/path")] // A relative URI.
[InlineData(" ")] // Only white space.
public async Task GetAsync_WhenThePersistedBaseUrlIsInvalid_ShouldKeepTheDefaultBaseUrl(string baseUrl)
{
// Arrange
@@ -109,15 +109,15 @@ public class MusicBrainzSettingsProviderTests
}
[Theory]
[InlineData("http://127.0.0.1/ws/2/")] // IPv4 loopback
[InlineData("http://localhost/ws/2/")] // loopback host name
[InlineData("http://[::1]/ws/2/")] // IPv6 loopback
[InlineData("http://169.254.169.254/latest/meta-data/")] // link local cloud metadata endpoint
[InlineData("http://10.0.0.5/ws/2/")] // private class A range
[InlineData("http://172.16.0.1/ws/2/")] // private class B range
[InlineData("http://192.168.1.10/ws/2/")] // private class C range
[InlineData("http://0.0.0.0/ws/2/")] // unspecified address
[InlineData("http://[fc00::1]/ws/2/")] // IPv6 unique local range
[InlineData("http://127.0.0.1/ws/2/")] // IPv4 loopback.
[InlineData("http://localhost/ws/2/")] // Loopback host name.
[InlineData("http://[::1]/ws/2/")] // IPv6 loopback.
[InlineData("http://169.254.169.254/latest/meta-data/")] // Link local cloud metadata endpoint.
[InlineData("http://10.0.0.5/ws/2/")] // Private class A range.
[InlineData("http://172.16.0.1/ws/2/")] // Private class B range.
[InlineData("http://192.168.1.10/ws/2/")] // Private class C range.
[InlineData("http://0.0.0.0/ws/2/")] // Unspecified address.
[InlineData("http://[fc00::1]/ws/2/")] // IPv6 unique local range.
public async Task GetAsync_WhenThePersistedBaseUrlPointsAtALocalOrPrivateHost_ShouldKeepTheDefaultBaseUrl(string baseUrl)
{
// Arrange
@@ -134,9 +134,9 @@ public class MusicBrainzSettingsProviderTests
}
[Theory]
[InlineData("http://192.168.1.10/ws/2/")] // private class C range, a typical self hosted mirror
[InlineData("http://localhost/ws/2/")] // loopback host name
[InlineData("http://[fc00::1]/ws/2/")] // IPv6 unique local range
[InlineData("http://192.168.1.10/ws/2/")] // Private class C range, a typical self hosted mirror.
[InlineData("http://localhost/ws/2/")] // Loopback host name.
[InlineData("http://[fc00::1]/ws/2/")] // IPv6 unique local range.
public async Task GetAsync_WhenPrivateBaseUrlsAreExplicitlyAllowed_ShouldApplyThem(string baseUrl)
{
// Arrange
@@ -157,11 +157,11 @@ public class MusicBrainzSettingsProviderTests
}
[Theory]
[InlineData("user\r\n@example.com")] // carriage return and line feed injection
[InlineData("user@example.com\r\nX-Injected: value")] // header injection attempt
[InlineData("user(comment)@example.com")] // parentheses break the user agent comment
[InlineData("user\"quoted\"@example.com")] // quotes break the header value
[InlineData("user example@example.com")] // an inner space is not a valid token character
[InlineData("user\r\n@example.com")] // Carriage return and line feed injection.
[InlineData("user@example.com\r\nX-Injected: value")] // Header injection attempt.
[InlineData("user(comment)@example.com")] // Parentheses break the user agent comment.
[InlineData("user\"quoted\"@example.com")] // Quotes break the header value.
[InlineData("user example@example.com")] // An inner space is not a valid token character.
public async Task GetAsync_WhenThePersistedContactEmailContainsUnsafeCharacters_ShouldDropIt(string storedEmail)
{
// Arrange
@@ -210,9 +210,9 @@ public class MusicBrainzSettingsProviderTests
}
[Theory]
[InlineData("", null)] // an empty value clears the email
[InlineData(" ", null)] // a white space value clears the email
[InlineData(" user@example.com ", "user@example.com")] // a value with surrounding white space is trimmed
[InlineData("", null)] // An empty value clears the email.
[InlineData(" ", null)] // A white space value clears the email.
[InlineData(" user@example.com ", "user@example.com")] // A value with surrounding white space is trimmed.
public async Task GetAsync_WhenThePersistedContactEmailIsPresent_ShouldSetOrClearIt(string storedEmail, string? expectedEmail)
{
// Arrange
@@ -230,9 +230,9 @@ public class MusicBrainzSettingsProviderTests
[Theory]
[InlineData("42", 42)]
[InlineData("0", 1)] // a limit of zero is clamped to one
[InlineData("-5", 1)] // a negative limit is clamped to one
[InlineData("not-a-number", 10)] // an unparsable value keeps the default
[InlineData("0", 1)] // A limit of zero is clamped to one.
[InlineData("-5", 1)] // A negative limit is clamped to one.
[InlineData("not-a-number", 10)] // An unparsable value keeps the default.
public async Task GetAsync_WhenThePersistedSearchResultLimitIsPresent_ShouldParseAndClampIt(string storedLimit, int expectedLimit)
{
// Arrange
@@ -250,9 +250,9 @@ public class MusicBrainzSettingsProviderTests
[Theory]
[InlineData("30", 30)]
[InlineData("0", 1)] // a limit of zero is clamped to one
[InlineData("-5", 1)] // a negative limit is clamped to one
[InlineData("not-a-number", 25)] // an unparsable value keeps the default
[InlineData("0", 1)] // A limit of zero is clamped to one.
[InlineData("-5", 1)] // A negative limit is clamped to one.
[InlineData("not-a-number", 25)] // An unparsable value keeps the default.
public async Task GetAsync_WhenThePersistedReleaseLookupLimitIsPresent_ShouldParseAndClampIt(string storedLimit, int expectedLimit)
{
// Arrange
@@ -270,9 +270,9 @@ public class MusicBrainzSettingsProviderTests
[Theory]
[InlineData("2.5", 2.5)]
[InlineData("0", 0)] // an interval of zero is allowed
[InlineData("-3", 0)] // a negative interval is clamped to zero
[InlineData("not-a-number", 1)] // an unparsable value keeps the default
[InlineData("0", 0)] // An interval of zero is allowed.
[InlineData("-3", 0)] // A negative interval is clamped to zero.
[InlineData("not-a-number", 1)] // An unparsable value keeps the default.
public async Task GetAsync_WhenThePersistedMinimumRequestIntervalIsPresent_ShouldParseAndClampIt(string storedInterval, double expectedSeconds)
{
// Arrange