mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
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:
1 parent
727aa33318
commit
057f557791
540 files changed
+3888
-3888
No files matched your search
+4
-4
@@ -59,17 +59,17 @@ public class JwtTokenGeneratorTests
|
||||
|
||||
JwtSecurityToken jwtToken = tokenHandler.ReadJwtToken(token);
|
||||
|
||||
// verify token properties
|
||||
// Verify token properties.
|
||||
Assert.Equal(_jwtSettings.Issuer, jwtToken.Issuer);
|
||||
Assert.Single(jwtToken.Audiences, _jwtSettings.Audience);
|
||||
Assert.Equal(_fixedUtcNow.AddMinutes(_jwtSettings.ExpiryMinutes), jwtToken.ValidTo);
|
||||
|
||||
// verify claims
|
||||
// Verify claims.
|
||||
Assert.Contains(jwtToken.Claims, c => c.Type == JwtRegisteredClaimNames.Sub && c.Value == userId);
|
||||
Assert.Contains(jwtToken.Claims, c => c.Type == JwtRegisteredClaimNames.UniqueName && c.Value == username);
|
||||
Assert.Contains(jwtToken.Claims, c => c.Type == JwtRegisteredClaimNames.Jti && c.Value == userId);
|
||||
|
||||
// verify the token is actually valid
|
||||
// Verify the token is actually valid.
|
||||
TokenValidationParameters validationParameters = new()
|
||||
{
|
||||
ValidateIssuerSigningKey = true,
|
||||
@@ -80,7 +80,7 @@ public class JwtTokenGeneratorTests
|
||||
ValidAudience = _jwtSettings.Audience,
|
||||
ValidateLifetime = true,
|
||||
ClockSkew = TimeSpan.Zero,
|
||||
// override the current time to match our fixed test time
|
||||
// Override the current time to match our fixed test time.
|
||||
LifetimeValidator = (notBefore, expires, token, parameters) => expires > _fixedUtcNow
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class QRCodeGeneratorTests
|
||||
|
||||
// Assert
|
||||
Assert.StartsWith("data:image/png;base64,", result);
|
||||
Assert.True(IsBase64String(result[22..])); // skip "data:image/png;base64,"
|
||||
Assert.True(IsBase64String(result[22..])); // Skip "data:image/png;base64,".
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -112,7 +112,7 @@ public class QRCodeGeneratorTests
|
||||
{
|
||||
// Arrange
|
||||
(string username, _) = QRCodeGeneratorFixture.CreateQrCodeTestData();
|
||||
byte[] shortSecret = [1]; // minimum length for Base32 encoding
|
||||
byte[] shortSecret = [1]; // Minimum length for Base32 encoding.
|
||||
|
||||
// Act
|
||||
string result = _sut.GenerateQrCodeDataUri(username, shortSecret);
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class TokenGeneratorTests
|
||||
string token = _sut.GenerateToken();
|
||||
|
||||
// Assert
|
||||
// 32 bytes in Base64 without padding should be 43 characters
|
||||
// 32 bytes in Base64 without padding should be 43 characters.
|
||||
Assert.Equal(43, token.Length);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -56,10 +56,10 @@ public class TotpTokenGeneratorTests
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData("123456")] // Valid format but wrong token
|
||||
[InlineData("abcdef")] // Invalid format
|
||||
[InlineData("12345")] // Too short
|
||||
[InlineData("1234567")] // Too long
|
||||
[InlineData("123456")] // Valid format but wrong token.
|
||||
[InlineData("abcdef")] // Invalid format.
|
||||
[InlineData("12345")] // Too short.
|
||||
[InlineData("1234567")] // Too long.
|
||||
public void ValidateToken_WhenTokenIsInvalid_ShouldReturnFalse(string invalidToken)
|
||||
{
|
||||
// Arrange
|
||||
@@ -95,6 +95,6 @@ public class TotpTokenGeneratorTests
|
||||
byte[] secret = _sut.GenerateSecret();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(20, secret.Length); // standard TOTP secret length
|
||||
Assert.Equal(20, secret.Length); // Standard TOTP secret length.
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -315,9 +315,9 @@ public class MusicArtworkServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("cover")] // a name without an extension falls back to the .img extension
|
||||
[InlineData("")] // an empty name falls back to the .img extension
|
||||
[InlineData(null)] // a null name falls back to the .img extension
|
||||
[InlineData("cover")] // A name without an extension falls back to the .img extension.
|
||||
[InlineData("")] // An empty name falls back to the .img extension.
|
||||
[InlineData(null)] // A null name falls back to the .img extension.
|
||||
public async Task SaveAlbumArtworkAsync_WhenTheUploadedFileNameHasNoExtension_ShouldBufferTheUploadWithTheImgExtension(string? fileName)
|
||||
{
|
||||
// Arrange
|
||||
@@ -427,9 +427,9 @@ public class MusicArtworkServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // a null path is a no-op
|
||||
[InlineData("")] // an empty path is a no-op
|
||||
[InlineData(" ")] // a whitespace path is a no-op
|
||||
[InlineData(null)] // A null path is a no-op.
|
||||
[InlineData("")] // An empty path is a no-op.
|
||||
[InlineData(" ")] // A whitespace path is a no-op.
|
||||
public void DeleteStoredArtwork_WhenThePathIsMissing_ShouldReturnDeletedWithoutTouchingTheFileSystem(string? artworkRelativePath)
|
||||
{
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -12,12 +12,12 @@ namespace Lumina.Infrastructure.UnitTests.Core.MediaLibrary.AudioLibrary.MusicLi
|
||||
public class AudioContainerResolverTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null, null)] // an absent mime type leaves the container unrecognized
|
||||
[InlineData("", null)] // an empty mime type leaves the container unrecognized
|
||||
[InlineData(" ", null)] // a blank mime type leaves the container unrecognized
|
||||
[InlineData("taglib/wav", "WAV")] // the taglib prefix is dropped and the container is upper cased
|
||||
[InlineData("taglib/png", "PNG")] // a container the resolver has no dedicated parser for still yields its name
|
||||
[InlineData("audio/x-wavpack", "X-WAVPACK")] // the last segment of a standard mime type names the container
|
||||
[InlineData(null, null)] // An absent mime type leaves the container unrecognized.
|
||||
[InlineData("", null)] // An empty mime type leaves the container unrecognized.
|
||||
[InlineData(" ", null)] // A blank mime type leaves the container unrecognized.
|
||||
[InlineData("taglib/wav", "WAV")] // The taglib prefix is dropped and the container is upper cased.
|
||||
[InlineData("taglib/png", "PNG")] // A container the resolver has no dedicated parser for still yields its name.
|
||||
[InlineData("audio/x-wavpack", "X-WAVPACK")] // The last segment of a standard mime type names the container.
|
||||
public void ResolveFromMimeType_WhenCalled_ShouldReturnTheContainerNamedByTheMimeType(string? mimeType, string? expectedContainer)
|
||||
{
|
||||
// Act
|
||||
|
||||
+4
-4
@@ -143,10 +143,10 @@ public class PlaybackDeliveryHandleServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // an absent handle cannot address a delivery
|
||||
[InlineData("")] // an empty handle cannot address a delivery
|
||||
[InlineData(" ")] // a whitespace handle cannot address a delivery
|
||||
[InlineData("0123456789abcdef0123456789abcdef")] // a well formed handle that was never issued
|
||||
[InlineData(null)] // An absent handle cannot address a delivery.
|
||||
[InlineData("")] // An empty handle cannot address a delivery.
|
||||
[InlineData(" ")] // A whitespace handle cannot address a delivery.
|
||||
[InlineData("0123456789abcdef0123456789abcdef")] // A well formed handle that was never issued.
|
||||
public void GetDelivery_WhenTheHandleIsMissingOrUnknown_ShouldReturnPlaybackDeliveryNotFoundError(string? deliveryId)
|
||||
{
|
||||
// Act
|
||||
|
||||
+16
-16
@@ -21,13 +21,13 @@ public class PlaybackFormatCatalogTests
|
||||
// Arrange
|
||||
(string Container, string Codec)[] expectedPairs =
|
||||
[
|
||||
("MP4", "AAC"), // the preferred container of the preferred codec
|
||||
("AAC", "AAC"), // the second container of the preferred codec
|
||||
("OGG", "OPUS"), // the preferred lossy codec after AAC
|
||||
("MP3", "MP3"), // the compatibility codec
|
||||
("OGG", "VORBIS"), // the second lossy codec in OGG
|
||||
("FLAC", "FLAC"), // the lossless codec
|
||||
("WAV", "PCM") // the uncompressed codec
|
||||
("MP4", "AAC"), // The preferred container of the preferred codec.
|
||||
("AAC", "AAC"), // The second container of the preferred codec.
|
||||
("OGG", "OPUS"), // The preferred lossy codec after AAC.
|
||||
("MP3", "MP3"), // The compatibility codec.
|
||||
("OGG", "VORBIS"), // The second lossy codec in OGG.
|
||||
("FLAC", "FLAC"), // The lossless codec.
|
||||
("WAV", "PCM") // The uncompressed codec.
|
||||
];
|
||||
|
||||
// Act
|
||||
@@ -80,7 +80,7 @@ public class PlaybackFormatCatalogTests
|
||||
Assert.True(result.TryGetValue(expectedEntry.Key, out IReadOnlyList<string>? containers));
|
||||
Assert.Equal(expectedEntry.Value, containers);
|
||||
}
|
||||
Assert.Equal(["MP4", "AAC"], result["AAC"]); // the preferred codec has two producible containers, in preference order
|
||||
Assert.Equal(["MP4", "AAC"], result["AAC"]); // The preferred codec has two producible containers, in preference order.
|
||||
Assert.Equal(["OGG"], result["OPUS"]);
|
||||
Assert.Equal(["OGG"], result["VORBIS"]);
|
||||
Assert.Equal(["MP3"], result["MP3"]);
|
||||
@@ -130,9 +130,9 @@ public class PlaybackFormatCatalogTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("mp4/aac", "MP4", "AAC")] // the canonical pair in lower case
|
||||
[InlineData("Mp4/Aac", "MP4", "AAC")] // the canonical pair in mixed case
|
||||
[InlineData("aac/aac", "AAC", "AAC")] // the second format in the catalog, in lower case
|
||||
[InlineData("mp4/aac", "MP4", "AAC")] // The canonical pair in lower case.
|
||||
[InlineData("Mp4/Aac", "MP4", "AAC")] // The canonical pair in mixed case.
|
||||
[InlineData("aac/aac", "AAC", "AAC")] // The second format in the catalog, in lower case.
|
||||
public void FormatsByPair_WhenLookedUpWithDifferentCasing_ShouldReturnTheCatalogFormat(string pairKey, string expectedContainer, string expectedCodec)
|
||||
{
|
||||
// Act
|
||||
@@ -167,11 +167,11 @@ public class PlaybackFormatCatalogTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null, "/")] // both parts are absent
|
||||
[InlineData("", "", "/")] // both parts are empty
|
||||
[InlineData(" ", " ", "/")] // both parts are white space
|
||||
[InlineData(null, "aac", "/AAC")] // only the container is absent
|
||||
[InlineData("mp4", null, "MP4/")] // only the codec is absent
|
||||
[InlineData(null, null, "/")] // Both parts are absent.
|
||||
[InlineData("", "", "/")] // Both parts are empty.
|
||||
[InlineData(" ", " ", "/")] // Both parts are white space.
|
||||
[InlineData(null, "aac", "/AAC")] // Only the container is absent.
|
||||
[InlineData("mp4", null, "MP4/")] // Only the codec is absent.
|
||||
public void BuildPairKey_WhenAContainerOrCodecIsNullOrEmpty_ShouldProduceTheSlashSeparatedFormWithoutThrowing(string? container, string? codec, string expectedKey)
|
||||
{
|
||||
// Act
|
||||
|
||||
+16
-16
@@ -122,16 +122,16 @@ public class PlaybackFormatServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MP3", "MPEG-1 Layer 3", "MP3")] // the free form description of an MPEG-1 Layer 3 stream
|
||||
[InlineData("MP3", "MP3", "MP3")] // a codec that is already named canonically
|
||||
[InlineData("FLAC", "Flac", "FLAC")] // the description of a FLAC stream
|
||||
[InlineData("OGG", "Vorbis I", "VORBIS")] // the description of a Vorbis stream
|
||||
[InlineData("OGG", "Opus", "OPUS")] // the description of an Opus stream
|
||||
[InlineData("MP4", "Apple Lossless", "ALAC")] // the description of an Apple Lossless stream
|
||||
[InlineData("AAC", "MPEG-4 AAC", "AAC")] // a description naming both MPEG and AAC is AAC, not MP3
|
||||
[InlineData("WAV", "PCM", "PCM")] // the description of an uncompressed stream
|
||||
[InlineData("WAV", "Uncompressed", "PCM")] // another description of an uncompressed stream
|
||||
[InlineData("WMA", "Windows Media Audio", "WMA")] // the description of a Windows Media stream
|
||||
[InlineData("MP3", "MPEG-1 Layer 3", "MP3")] // The free form description of an MPEG-1 Layer 3 stream.
|
||||
[InlineData("MP3", "MP3", "MP3")] // A codec that is already named canonically.
|
||||
[InlineData("FLAC", "Flac", "FLAC")] // The description of a FLAC stream.
|
||||
[InlineData("OGG", "Vorbis I", "VORBIS")] // The description of a Vorbis stream.
|
||||
[InlineData("OGG", "Opus", "OPUS")] // The description of an Opus stream.
|
||||
[InlineData("MP4", "Apple Lossless", "ALAC")] // The description of an Apple Lossless stream.
|
||||
[InlineData("AAC", "MPEG-4 AAC", "AAC")] // A description naming both MPEG and AAC is AAC, not MP3.
|
||||
[InlineData("WAV", "PCM", "PCM")] // The description of an uncompressed stream.
|
||||
[InlineData("WAV", "Uncompressed", "PCM")] // Another description of an uncompressed stream.
|
||||
[InlineData("WMA", "Windows Media Audio", "WMA")] // The description of a Windows Media stream.
|
||||
public void DecideDelivery_WhenTheStoredCodecDescriptionIsRecognizable_ShouldCanonicalizeItAndDirectPlay(string container, string codecDescription, string canonicalCodec)
|
||||
{
|
||||
// Arrange
|
||||
@@ -148,9 +148,9 @@ public class PlaybackFormatServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MPEG-1 Layer 2")] // MP2 shares the MP3 container but an MP3 decoder cannot decode it
|
||||
[InlineData("MPEG-1 Layer 1")] // MP1 shares the MP3 container but an MP3 decoder cannot decode it
|
||||
[InlineData("MPEG-4 Audio")] // a description that names no decodable codec is not mistaken for MP3
|
||||
[InlineData("MPEG-1 Layer 2")] // MP2 shares the MP3 container but an MP3 decoder cannot decode it.
|
||||
[InlineData("MPEG-1 Layer 1")] // MP1 shares the MP3 container but an MP3 decoder cannot decode it.
|
||||
[InlineData("MPEG-4 Audio")] // A description that names no decodable codec is not mistaken for MP3.
|
||||
public void DecideDelivery_WhenAnMpegDescriptionIsNotLayer3_ShouldReturnTranscode(string codecDescription)
|
||||
{
|
||||
// Arrange
|
||||
@@ -166,9 +166,9 @@ public class PlaybackFormatServiceTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)] // an absent probe result names no codec
|
||||
[InlineData("", "")] // an empty probe result names no codec
|
||||
[InlineData("MP3", "AC-3")] // a codec description the server does not recognize
|
||||
[InlineData(null, null)] // An absent probe result names no codec.
|
||||
[InlineData("", "")] // An empty probe result names no codec.
|
||||
[InlineData("MP3", "AC-3")] // A codec description the server does not recognize.
|
||||
public void DecideDelivery_WhenTheStoredFormatIsUnknown_ShouldReturnTranscode(string? container, string? codec)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+2
-2
@@ -92,8 +92,8 @@ public class TrackNormalizationServiceTests : IDisposable
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // the source file length no longer matches the declared delivery
|
||||
[InlineData(false)] // the source file modification time no longer matches the declared delivery
|
||||
[InlineData(true)] // The source file length no longer matches the declared delivery.
|
||||
[InlineData(false)] // The source file modification time no longer matches the declared delivery.
|
||||
public async Task GetOrCreateNormalizedTrackAsync_WhenTheSourceFileChangedSinceTheDeliveryWasDeclared_ShouldReturnPlaybackDeliveryChangedError(bool isLengthChanged)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ public class TranscodingToolchainStatusTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("AAC")] // an encoder name in upper case
|
||||
[InlineData("Aac")] // an encoder name in mixed case
|
||||
[InlineData("AAC")] // An encoder name in upper case.
|
||||
[InlineData("Aac")] // An encoder name in mixed case.
|
||||
public void RecordMissingEncoders_WhenTheNameDiffersInCase_ShouldReportTheEncoderUnavailable(string missingEncoderName)
|
||||
{
|
||||
// Act
|
||||
|
||||
+28
-28
@@ -26,8 +26,8 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\', @"C:\Music\Queen\A Night at the Opera", @"C:\Music\Queen\A Night at the Opera\Bohemian Rhapsody.flac")] // Windows separated path
|
||||
[InlineData('/', "/music/queen/a-night-at-the-opera", "/music/queen/a-night-at-the-opera/bohemian-rhapsody.flac")] // Unix separated path
|
||||
[InlineData('\\', @"C:\Music\Queen\A Night at the Opera", @"C:\Music\Queen\A Night at the Opera\Bohemian Rhapsody.flac")] // Windows separated path.
|
||||
[InlineData('/', "/music/queen/a-night-at-the-opera", "/music/queen/a-night-at-the-opera/bohemian-rhapsody.flac")] // Unix separated path.
|
||||
public void GetAlbumDirectory_WhenTheTrackIsInTheAlbumDirectory_ShouldReturnTheTrackDirectory(char separator, string albumDirectory, string trackPath)
|
||||
{
|
||||
// Arrange
|
||||
@@ -41,14 +41,14 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\', "Disc 1")] // canonical disc directory name, Windows separated path
|
||||
[InlineData('\\', "disc 2")] // lowercase disc directory name, Windows separated path
|
||||
[InlineData('\\', "CD3")] // compact disc directory name, Windows separated path
|
||||
[InlineData('\\', "disk4")] // disk directory name, Windows separated path
|
||||
[InlineData('/', "Disc 1")] // canonical disc directory name, Unix separated path
|
||||
[InlineData('/', "disc 2")] // lowercase disc directory name, Unix separated path
|
||||
[InlineData('/', "CD3")] // compact disc directory name, Unix separated path
|
||||
[InlineData('/', "disk4")] // disk directory name, Unix separated path
|
||||
[InlineData('\\', "Disc 1")] // Canonical disc directory name, Windows separated path.
|
||||
[InlineData('\\', "disc 2")] // Lowercase disc directory name, Windows separated path.
|
||||
[InlineData('\\', "CD3")] // Compact disc directory name, Windows separated path.
|
||||
[InlineData('\\', "disk4")] // Disk directory name, Windows separated path.
|
||||
[InlineData('/', "Disc 1")] // Canonical disc directory name, Unix separated path.
|
||||
[InlineData('/', "disc 2")] // Lowercase disc directory name, Unix separated path.
|
||||
[InlineData('/', "CD3")] // Compact disc directory name, Unix separated path.
|
||||
[InlineData('/', "disk4")] // Disk directory name, Unix separated path.
|
||||
public void GetAlbumDirectory_WhenTheTrackIsInADiscDirectory_ShouldReturnTheParentAlbumDirectory(char separator, string discDirectoryName)
|
||||
{
|
||||
// Arrange
|
||||
@@ -64,8 +64,8 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\')] // Windows separated path
|
||||
[InlineData('/')] // Unix separated path
|
||||
[InlineData('\\')] // Windows separated path.
|
||||
[InlineData('/')] // Unix separated path.
|
||||
public void GetAlbumDirectory_WhenTheDirectoryIsNotADiscDirectory_ShouldReturnTheTrackDirectory(char separator)
|
||||
{
|
||||
// Arrange
|
||||
@@ -93,8 +93,8 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\')] // Windows separated path
|
||||
[InlineData('/')] // Unix separated path
|
||||
[InlineData('\\')] // Windows separated path.
|
||||
[InlineData('/')] // Unix separated path.
|
||||
public void GetAlbumDirectory_WhenThePathHasNoDirectory_ShouldReturnTheProvidedPath(char separator)
|
||||
{
|
||||
// Arrange
|
||||
@@ -109,10 +109,10 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\', "Album")] // canonical release type directory, Windows separated path
|
||||
[InlineData('\\', "album")] // lowercase release type directory, Windows separated path
|
||||
[InlineData('/', "Album")] // canonical release type directory, Unix separated path
|
||||
[InlineData('/', "album")] // lowercase release type directory, Unix separated path
|
||||
[InlineData('\\', "Album")] // Canonical release type directory, Windows separated path.
|
||||
[InlineData('\\', "album")] // Lowercase release type directory, Windows separated path.
|
||||
[InlineData('/', "Album")] // Canonical release type directory, Unix separated path.
|
||||
[InlineData('/', "album")] // Lowercase release type directory, Unix separated path.
|
||||
public void GetReleaseTypeDirectoryName_WhenTheParentOfTheAlbumDirectoryIsAReleaseType_ShouldReturnIt(char separator, string releaseTypeDirectoryName)
|
||||
{
|
||||
// Arrange
|
||||
@@ -127,8 +127,8 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\')] // Windows separated path
|
||||
[InlineData('/')] // Unix separated path
|
||||
[InlineData('\\')] // Windows separated path.
|
||||
[InlineData('/')] // Unix separated path.
|
||||
public void GetReleaseTypeDirectoryName_WhenTheAlbumIsMultiDisc_ShouldReturnTheReleaseTypeDirectory(char separator)
|
||||
{
|
||||
// Arrange
|
||||
@@ -143,8 +143,8 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\')] // Windows separated path
|
||||
[InlineData('/')] // Unix separated path
|
||||
[InlineData('\\')] // Windows separated path.
|
||||
[InlineData('/')] // Unix separated path.
|
||||
public void GetReleaseTypeDirectoryName_WhenTheParentOfTheAlbumDirectoryIsNotAReleaseType_ShouldReturnNull(char separator)
|
||||
{
|
||||
// Arrange
|
||||
@@ -159,10 +159,10 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\', "Live")] // release type name used as the artist directory name, Windows separated path
|
||||
[InlineData('/', "Live")] // release type name used as the artist directory name, Unix separated path
|
||||
[InlineData('\\', "42")] // numeric artist directory name, Windows separated path
|
||||
[InlineData('/', "42")] // numeric artist directory name, Unix separated path
|
||||
[InlineData('\\', "Live")] // Release type name used as the artist directory name, Windows separated path.
|
||||
[InlineData('/', "Live")] // Release type name used as the artist directory name, Unix separated path.
|
||||
[InlineData('\\', "42")] // Numeric artist directory name, Windows separated path.
|
||||
[InlineData('/', "42")] // Numeric artist directory name, Unix separated path.
|
||||
public void GetReleaseTypeDirectoryName_WhenTheArtistDirectoryIsNamedLikeAReleaseType_ShouldReturnNull(char separator, string artistName)
|
||||
{
|
||||
// Arrange
|
||||
@@ -178,8 +178,8 @@ public class MusicLibraryPathStructureTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData('\\')] // Windows separated path
|
||||
[InlineData('/')] // Unix separated path
|
||||
[InlineData('\\')] // Windows separated path.
|
||||
[InlineData('/')] // Unix separated path.
|
||||
public void GetReleaseTypeDirectoryName_WhenAReleaseTypeDirectoryDiffersFromTheArtistDirectory_ShouldReturnIt(char separator)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -103,7 +103,7 @@ public class MusicMediaLibraryScanMetadataEnricherTests
|
||||
_userId = _userIdFixture.Create();
|
||||
_libraryId = _libraryIdFixture.Create();
|
||||
|
||||
// the configured providers are registered under the plugin Ids they are configured with, the way the host registers plugin provided services
|
||||
// The configured providers are registered under the plugin Ids they are configured with, the way the host registers plugin provided services.
|
||||
Guid pluginAId = Guid.NewGuid();
|
||||
Guid pluginBId = Guid.NewGuid();
|
||||
_mockMetadataConfigurationRepository.GetByLibraryIdAsync(_libraryId.Value, Arg.Any<CancellationToken>())
|
||||
@@ -153,7 +153,7 @@ public class MusicMediaLibraryScanMetadataEnricherTests
|
||||
await _sut.EnrichAsync(_libraryId, _scanId, _userId, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
// the total is the sum of the artists, the albums and the tracks, and the final update reaches it
|
||||
// The total is the sum of the artists, the albums and the tracks, and the final update reaches it.
|
||||
await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is<LibraryScanJobProgressChangedDomainEvent>(domainEvent =>
|
||||
domainEvent.MediaLibraryScanCompositeId.ScanId == _scanId
|
||||
&& domainEvent.Progress.CompletedItems == 0
|
||||
@@ -215,7 +215,7 @@ public class MusicMediaLibraryScanMetadataEnricherTests
|
||||
ArtistEntity artist = _artistEntityFixture.Create(libraryId: _libraryId.Value);
|
||||
_mockArtistRepository.GetArtistsNeedingMetadataAsync(_libraryId.Value, Arg.Any<string?>(), Arg.Any<int>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result<IReadOnlyList<ArtistEntity>>.Success([artist]), Result<IReadOnlyList<ArtistEntity>>.Success([]));
|
||||
// a genre without a name is usable as metadata, but makes the domain conversion of the whole metadata fail
|
||||
// A genre without a name is usable as metadata, but makes the domain conversion of the whole metadata fail.
|
||||
_mockProviderA.GetMetadataAsync(Arg.Any<MetadataLookupDto>(), Arg.Any<CancellationToken>())
|
||||
.Returns((MetadataDto?)CreateApplicableArtistMetadata("Local Artist", genres: [_genreDtoFixture.Create(includeName: false)]));
|
||||
_mockProviderB.GetMetadataAsync(Arg.Any<MetadataLookupDto>(), Arg.Any<CancellationToken>())
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class MediaLibraryScanArtworkEnrichmentJobTests
|
||||
_mockUnitOfWork.LibraryRepository.Returns(_mockLibraryRepository);
|
||||
_mockServiceProvider.GetService(typeof(IUnitOfWork)).Returns(_mockUnitOfWork);
|
||||
|
||||
// the job resolves the artwork enricher of the loaded library type from the service scope, so the music enricher must be available
|
||||
// The job resolves the artwork enricher of the loaded library type from the service scope, so the music enricher must be available.
|
||||
_mockArtworkEnricher = Substitute.For<IMediaLibraryScanArtworkEnricher>();
|
||||
_mockArtworkEnricher.SupportedLibraryType.Returns(LibraryType.Music);
|
||||
_mockArtworkEnricher.EnrichAsync(Arg.Any<LibraryId>(), Arg.Any<ScanId>(), Arg.Any<UserId>(), Arg.Any<CancellationToken>())
|
||||
|
||||
+1
-1
@@ -349,7 +349,7 @@ public class MediaLibraryScanHashJobTests
|
||||
|
||||
// Assert
|
||||
Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status);
|
||||
// the initial progress and the progress published from the hashing callback are both reported
|
||||
// The initial progress and the progress published from the hashing callback are both reported.
|
||||
await _mockDomainEventPublisher.Received(2).PublishAsync(Arg.Is<LibraryScanJobProgressChangedDomainEvent>(domainEvent => domainEvent.LibraryId == _libraryId), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -20,7 +20,7 @@ public class MediaLibraryScanProgressHubTests
|
||||
[Fact]
|
||||
public async Task SubscribeToScan_WhenCalled_ShouldAddTheConnectionToTheGroupOfTheAuthenticatedUser()
|
||||
{
|
||||
// Arrange.
|
||||
// Arrange
|
||||
MediaLibraryScanProgressHub sut = new();
|
||||
HubCallerContext context = Substitute.For<HubCallerContext>();
|
||||
context.ConnectionId.Returns("connection-1");
|
||||
@@ -33,17 +33,17 @@ public class MediaLibraryScanProgressHubTests
|
||||
ClaimsPrincipal user = new(new ClaimsIdentity([new Claim(ClaimTypes.NameIdentifier, userId.ToString())]));
|
||||
context.User.Returns(user);
|
||||
|
||||
// Act.
|
||||
// Act
|
||||
await sut.SubscribeToScan(scanId);
|
||||
|
||||
// Assert.
|
||||
// Assert
|
||||
await groupManager.Received(1).AddToGroupAsync("connection-1", $"{scanId}-{userId}", CancellationToken.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SubscribeToScan_WhenUserClaimIsMissing_ShouldNotAddTheConnectionToAnyGroup()
|
||||
{
|
||||
// Arrange.
|
||||
// Arrange
|
||||
MediaLibraryScanProgressHub sut = new();
|
||||
HubCallerContext context = Substitute.For<HubCallerContext>();
|
||||
context.ConnectionId.Returns("connection-1");
|
||||
@@ -54,17 +54,17 @@ public class MediaLibraryScanProgressHubTests
|
||||
ClaimsPrincipal user = new(new ClaimsIdentity());
|
||||
context.User.Returns(user);
|
||||
|
||||
// Act.
|
||||
// Act
|
||||
await sut.SubscribeToScan(scanId);
|
||||
|
||||
// Assert.
|
||||
// Assert
|
||||
await groupManager.DidNotReceive().AddToGroupAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SubscribeToScan_WhenUserIdClaimIsNotAGuid_ShouldNotAddTheConnectionToAnyGroup()
|
||||
{
|
||||
// Arrange.
|
||||
// Arrange
|
||||
MediaLibraryScanProgressHub sut = new();
|
||||
HubCallerContext context = Substitute.For<HubCallerContext>();
|
||||
context.ConnectionId.Returns("connection-1");
|
||||
@@ -75,10 +75,10 @@ public class MediaLibraryScanProgressHubTests
|
||||
ClaimsPrincipal user = new(new ClaimsIdentity([new Claim(ClaimTypes.NameIdentifier, "not-a-guid")]));
|
||||
context.User.Returns(user);
|
||||
|
||||
// Act.
|
||||
// Act
|
||||
await sut.SubscribeToScan(scanId);
|
||||
|
||||
// Assert.
|
||||
// Assert
|
||||
await groupManager.DidNotReceive().AddToGroupAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class MediaLibraryScanProcessorJobTests : IDisposable
|
||||
RegisterScan(firstScanId, LibraryScanJobStatus.Pending);
|
||||
RegisterScan(secondScanId, LibraryScanJobStatus.Pending);
|
||||
TaskCompletionSource<bool> releaseFirstScan = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
// ExecutionStarted is signaled before the callback runs, and resumes the test on another thread, so the test waits for the callback itself to record the scan
|
||||
// ExecutionStarted is signaled before the callback runs, and resumes the test on another thread, so the test waits for the callback itself to record the scan.
|
||||
TaskCompletionSource firstScanRecorded = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
List<Guid> startedScanIds = [];
|
||||
FakeMediaLibraryScanDiscoveryJob firstRootJob = _mediaLibraryScanDiscoveryJobFixture.Create(onExecute: async _ =>
|
||||
|
||||
+2
-2
@@ -25,8 +25,8 @@ public class BookReaderEnablementCacheTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // reader enabled
|
||||
[InlineData(false)] // reader disabled
|
||||
[InlineData(true)] // Reader enabled.
|
||||
[InlineData(false)] // Reader disabled.
|
||||
public void Set_WhenCalled_ThenGetShouldReturnTheCachedValue(bool isEnabled)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -126,8 +126,8 @@ public class ReadingContentSanitizerTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // preserve styles
|
||||
[InlineData(false)] // strip styles
|
||||
[InlineData(true)] // Preserve styles.
|
||||
[InlineData(false)] // Strip styles.
|
||||
public void Sanitize_WhenHtmlContainsActiveContent_ShouldStripItRegardlessOfTheStylePreference(bool shouldPreserveStyles)
|
||||
{
|
||||
// Arrange
|
||||
@@ -145,9 +145,9 @@ public class ReadingContentSanitizerTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // null input
|
||||
[InlineData("")] // empty input
|
||||
[InlineData(" ")] // whitespace input
|
||||
[InlineData(null)] // Null input.
|
||||
[InlineData("")] // Empty input.
|
||||
[InlineData(" ")] // Whitespace input.
|
||||
public void Sanitize_WhenInputIsBlank_ShouldReturnEmptyString(string? html)
|
||||
{
|
||||
// Act
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ public class CryptographyServiceTests
|
||||
public void Decrypt_WhenInputIsTooShort_ShouldThrowArgumentException()
|
||||
{
|
||||
// Arrange
|
||||
string shortCiphertext = Convert.ToBase64String(new byte[8]); // less than required 16 bytes
|
||||
string shortCiphertext = Convert.ToBase64String(new byte[8]); // Less than required 16 bytes.
|
||||
|
||||
// Act
|
||||
Action act = () => _sut.Decrypt(shortCiphertext);
|
||||
@@ -135,7 +135,7 @@ public class CryptographyServiceTests
|
||||
|
||||
// Decode the Base64 string, modify one byte, then re-encode.
|
||||
byte[] encryptedBytes = Convert.FromBase64String(encrypted);
|
||||
encryptedBytes[^1] ^= 0xFF; // flip all bits in the last byte
|
||||
encryptedBytes[^1] ^= 0xFF; // Flip all bits in the last byte.
|
||||
string corrupted = Convert.ToBase64String(encryptedBytes);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -57,7 +57,7 @@ public class HashServiceTests
|
||||
// Assert
|
||||
Assert.NotNull(hash);
|
||||
Assert.NotEmpty(hash);
|
||||
// verify it's a valid Base64 string
|
||||
// Verify it's a valid Base64 string.
|
||||
Assert.NotNull(Convert.FromBase64String(hash));
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ public class HashServiceTests
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("dGVzdA==")] // valid base64 but wrong length
|
||||
[InlineData("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=")] // valid base64 but wrong length
|
||||
[InlineData("dGVzdA==")] // Valid base64 but wrong length.
|
||||
[InlineData("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=")] // Valid base64 but wrong length.
|
||||
public void CheckStringAgainstHash_WhenHashIsInvalidLength_ShouldReturnFalse(string invalidHash)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ThemeMimeTypesTests
|
||||
public void GetMimeType_WhenExtensionIsKnown_ShouldReturnMappedContentType(string filePath, string expectedContentType)
|
||||
{
|
||||
// Arrange
|
||||
// filePath and expectedContentType are provided by the test data
|
||||
// filePath and expectedContentType are provided by the test data.
|
||||
|
||||
// Act
|
||||
string result = ThemeMimeTypes.GetMimeType(filePath);
|
||||
|
||||
Reference in new issue
Block a user