mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+101
@@ -0,0 +1,101 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.CoverArtArchive.Common.Models.Contracts.Responses;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.CoverArtArchive.UnitTests.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="CoverArtArchiveArtworkResponse"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CoverArtArchiveArtworkResponseTests
|
||||
{
|
||||
[Fact]
|
||||
public void Deserialize_WhenTheApiReturnsImages_ShouldDeserializeEveryImage()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = """
|
||||
{
|
||||
"images": [
|
||||
{ "image": "https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/1.jpg", "front": true, "types": [ "Front" ] },
|
||||
{ "image": "https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/2.jpg", "back": true, "types": [ "Back" ] }
|
||||
]
|
||||
}
|
||||
""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveArtworkResponse? response = JsonSerializer.Deserialize<CoverArtArchiveArtworkResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Images);
|
||||
Assert.Equal(2, response.Images.Count);
|
||||
Assert.Equal("https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/1.jpg", response.Images[0]!.Image);
|
||||
Assert.Equal(["Front"], response.Images[0]!.Types);
|
||||
Assert.Equal("https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/2.jpg", response.Images[1]!.Image);
|
||||
Assert.Equal(["Back"], response.Images[1]!.Types);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenTheApiReturnsANullImagesCollection_ShouldDeserializeAsNull()
|
||||
{
|
||||
// Arrange
|
||||
// The API can answer with a null images collection, which must not be turned into anything else by the deserializer.
|
||||
const string JSON = """{"images":null}""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveArtworkResponse? response = JsonSerializer.Deserialize<CoverArtArchiveArtworkResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Null(response.Images);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenTheImagesCollectionContainsNullElements_ShouldKeepThem()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = """{"images":[null,{"image":"https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/1.jpg"}]}""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveArtworkResponse? response = JsonSerializer.Deserialize<CoverArtArchiveArtworkResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Images);
|
||||
Assert.Equal(2, response.Images.Count);
|
||||
Assert.Null(response.Images[0]);
|
||||
Assert.NotNull(response.Images[1]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenTheImagesCollectionIsEmpty_ShouldDeserializeAsEmpty()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = """{"images":[]}""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveArtworkResponse? response = JsonSerializer.Deserialize<CoverArtArchiveArtworkResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Images);
|
||||
Assert.Empty(response.Images);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenThePropertyIsMissing_ShouldDefaultToNull()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = "{}";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveArtworkResponse? response = JsonSerializer.Deserialize<CoverArtArchiveArtworkResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Null(response.Images);
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.CoverArtArchive.Common.Models.Contracts.Responses;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.CoverArtArchive.UnitTests.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="CoverArtArchiveImageResponse"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CoverArtArchiveImageResponseTests
|
||||
{
|
||||
[Fact]
|
||||
public void Deserialize_WhenEveryFieldIsPresent_ShouldDeserializeEveryProperty()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = """
|
||||
{
|
||||
"approved": true,
|
||||
"back": true,
|
||||
"comment": "A comment",
|
||||
"front": false,
|
||||
"id": 12345,
|
||||
"image": "https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/12345.jpg",
|
||||
"thumbnail": "https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/12345-250.jpg",
|
||||
"types": [ "Back", "Booklet" ]
|
||||
}
|
||||
""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveImageResponse? response = JsonSerializer.Deserialize<CoverArtArchiveImageResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal("https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/12345.jpg", response.Image);
|
||||
Assert.Equal("https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/12345-250.jpg", response.Thumbnail);
|
||||
Assert.Equal(["Back", "Booklet"], response.Types);
|
||||
Assert.False(response.IsFront);
|
||||
Assert.True(response.IsBack);
|
||||
Assert.Equal("A comment", response.Comment);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenTheApiReturnsANullTypes_ShouldDeserializeAsNull()
|
||||
{
|
||||
// Arrange
|
||||
// The API can answer with a null types collection, which must not be turned into anything else by the deserializer.
|
||||
const string JSON = """{"image":"https://coverartarchive.org/release/11111111-1111-1111-1111-111111111111/1.jpg","types":null}""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveImageResponse? response = JsonSerializer.Deserialize<CoverArtArchiveImageResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Null(response.Types);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenTheTypesCollectionContainsNullElements_ShouldKeepThem()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = """{"types":["Front",null,"Booklet"]}""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveImageResponse? response = JsonSerializer.Deserialize<CoverArtArchiveImageResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Types);
|
||||
Assert.Equal(["Front", null, "Booklet"], response.Types);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenTheApiReturnsANullImage_ShouldDeserializeAsNull()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = """{"image":null,"types":["Front"]}""";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveImageResponse? response = JsonSerializer.Deserialize<CoverArtArchiveImageResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Null(response.Image);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_WhenThePropertiesAreMissing_ShouldDefaultToNullAndFalse()
|
||||
{
|
||||
// Arrange
|
||||
const string JSON = "{}";
|
||||
|
||||
// Act
|
||||
CoverArtArchiveImageResponse? response = JsonSerializer.Deserialize<CoverArtArchiveImageResponse>(JSON);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Null(response.Image);
|
||||
Assert.Null(response.Thumbnail);
|
||||
Assert.Null(response.Types);
|
||||
Assert.False(response.IsFront);
|
||||
Assert.False(response.IsBack);
|
||||
Assert.Null(response.Comment);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user