mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 05:11:10 +00:00
Hardens test assertions and adds missing test coverage.
This commit is contained in:
1 parent
6b86fd5805
commit
1189bbaf36
489 files changed
+39982
-512
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="BookFormat"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookFormatTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void BookFormat_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
BookFormat[] values = Enum.GetValues<BookFormat>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (BookFormat value in Enum.GetValues<BookFormat>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
BookFormat deserialized = JsonSerializer.Deserialize<BookFormat>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="BookRatingSource"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookRatingSourceTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void BookRatingSource_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
BookRatingSource[] values = Enum.GetValues<BookRatingSource>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (BookRatingSource value in Enum.GetValues<BookRatingSource>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
BookRatingSource deserialized = JsonSerializer.Deserialize<BookRatingSource>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="IsbnFormat"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class IsbnFormatTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void IsbnFormat_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
IsbnFormat[] values = Enum.GetValues<IsbnFormat>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (IsbnFormat value in Enum.GetValues<IsbnFormat>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
IsbnFormat deserialized = JsonSerializer.Deserialize<IsbnFormat>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="MetadataStatus"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MetadataStatusTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void MetadataStatus_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
MetadataStatus[] values = Enum.GetValues<MetadataStatus>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (MetadataStatus value in Enum.GetValues<MetadataStatus>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
MetadataStatus deserialized = JsonSerializer.Deserialize<MetadataStatus>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="WrittenContentType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class WrittenContentTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void WrittenContentType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
WrittenContentType[] values = Enum.GetValues<WrittenContentType>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (WrittenContentType value in Enum.GetValues<WrittenContentType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
WrittenContentType deserialized = JsonSerializer.Deserialize<WrittenContentType>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user