mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11: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.AudioLibrary;
|
||||
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.AudioLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="AudioContentType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudioContentTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void AudioContentType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
AudioContentType[] values = Enum.GetValues<AudioContentType>();
|
||||
|
||||
// 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 (AudioContentType value in Enum.GetValues<AudioContentType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
AudioContentType deserialized = JsonSerializer.Deserialize<AudioContentType>(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.AudioLibrary;
|
||||
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.AudioLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="AudioRatingSource"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudioRatingSourceTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void AudioRatingSource_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
AudioRatingSource[] values = Enum.GetValues<AudioRatingSource>();
|
||||
|
||||
// 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 (AudioRatingSource value in Enum.GetValues<AudioRatingSource>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
AudioRatingSource deserialized = JsonSerializer.Deserialize<AudioRatingSource>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
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.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="AuthorizationPermission"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AuthorizationPermissionTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void AuthorizationPermission_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
AuthorizationPermission[] values = Enum.GetValues<AuthorizationPermission>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void None_WhenCastingToInteger_ShouldBeZero()
|
||||
{
|
||||
// Act
|
||||
int value = (int)AuthorizationPermission.None;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(0, value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (AuthorizationPermission value in Enum.GetValues<AuthorizationPermission>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
AuthorizationPermission deserialized = JsonSerializer.Deserialize<AuthorizationPermission>(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="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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
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.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="SortOrder"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SortOrderTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void SortOrder_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
SortOrder[] values = Enum.GetValues<SortOrder>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ascending_WhenCastingToInteger_ShouldBeZero()
|
||||
{
|
||||
// Act
|
||||
int value = (int)SortOrder.Ascending;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(0, value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (SortOrder value in Enum.GetValues<SortOrder>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
SortOrder deserialized = JsonSerializer.Deserialize<SortOrder>(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.FileSystem;
|
||||
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.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="FileAccessMode"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileAccessModeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void FileAccessMode_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
FileAccessMode[] values = Enum.GetValues<FileAccessMode>();
|
||||
|
||||
// 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 (FileAccessMode value in Enum.GetValues<FileAccessMode>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
FileAccessMode deserialized = JsonSerializer.Deserialize<FileAccessMode>(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.FileSystem;
|
||||
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.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="FileSystemItemStatus"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemItemStatusTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void FileSystemItemStatus_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
FileSystemItemStatus[] values = Enum.GetValues<FileSystemItemStatus>();
|
||||
|
||||
// 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 (FileSystemItemStatus value in Enum.GetValues<FileSystemItemStatus>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
FileSystemItemStatus deserialized = JsonSerializer.Deserialize<FileSystemItemStatus>(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.FileSystem;
|
||||
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.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="FileSystemItemType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemItemTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void FileSystemItemType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
FileSystemItemType[] values = Enum.GetValues<FileSystemItemType>();
|
||||
|
||||
// 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 (FileSystemItemType value in Enum.GetValues<FileSystemItemType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
FileSystemItemType deserialized = JsonSerializer.Deserialize<FileSystemItemType>(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.FileSystem;
|
||||
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.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PlatformType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlatformTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void PlatformType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PlatformType[] values = Enum.GetValues<PlatformType>();
|
||||
|
||||
// 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 (PlatformType value in Enum.GetValues<PlatformType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
PlatformType deserialized = JsonSerializer.Deserialize<PlatformType>(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.MediaLibrary;
|
||||
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.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="LibraryScanFileStatus"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanFileStatusTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void LibraryScanFileStatus_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
LibraryScanFileStatus[] values = Enum.GetValues<LibraryScanFileStatus>();
|
||||
|
||||
// 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 (LibraryScanFileStatus value in Enum.GetValues<LibraryScanFileStatus>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
LibraryScanFileStatus deserialized = JsonSerializer.Deserialize<LibraryScanFileStatus>(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.MediaLibrary;
|
||||
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.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="LibraryScanJobStatus"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanJobStatusTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void LibraryScanJobStatus_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
LibraryScanJobStatus[] values = Enum.GetValues<LibraryScanJobStatus>();
|
||||
|
||||
// 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 (LibraryScanJobStatus value in Enum.GetValues<LibraryScanJobStatus>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
LibraryScanJobStatus deserialized = JsonSerializer.Deserialize<LibraryScanJobStatus>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
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.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="LibraryType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void LibraryType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
LibraryType[] values = Enum.GetValues<LibraryType>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Book_WhenCastingToInteger_ShouldBeZero()
|
||||
{
|
||||
// Act
|
||||
int value = (int)LibraryType.Book;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(0, value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (LibraryType value in Enum.GetValues<LibraryType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
LibraryType deserialized = JsonSerializer.Deserialize<LibraryType>(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.MediaLibrary;
|
||||
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.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="MiscellaneousContentType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MiscellaneousContentTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void MiscellaneousContentType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
MiscellaneousContentType[] values = Enum.GetValues<MiscellaneousContentType>();
|
||||
|
||||
// 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 (MiscellaneousContentType value in Enum.GetValues<MiscellaneousContentType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
MiscellaneousContentType deserialized = JsonSerializer.Deserialize<MiscellaneousContentType>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
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.PhotoLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ImageType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ImageTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void ImageType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
ImageType[] values = Enum.GetValues<ImageType>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
Assert.All(values, value => Assert.True(Enum.IsDefined(value)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void None_WhenCastingToInteger_ShouldBeZero()
|
||||
{
|
||||
// Act
|
||||
int value = (int)ImageType.None;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(0, value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithCamelCaseConverter_ShouldPreserveEnumValue()
|
||||
{
|
||||
// Arrange
|
||||
foreach (ImageType value in Enum.GetValues<ImageType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
ImageType deserialized = JsonSerializer.Deserialize<ImageType>(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.PhotoLibrary;
|
||||
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.PhotoLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="VisualContentType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VisualContentTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void VisualContentType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
VisualContentType[] values = Enum.GetValues<VisualContentType>();
|
||||
|
||||
// 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 (VisualContentType value in Enum.GetValues<VisualContentType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
VisualContentType deserialized = JsonSerializer.Deserialize<VisualContentType>(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.Plugins;
|
||||
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.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PluginLoadStatus"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginLoadStatusTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void PluginLoadStatus_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PluginLoadStatus[] values = Enum.GetValues<PluginLoadStatus>();
|
||||
|
||||
// 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 (PluginLoadStatus value in Enum.GetValues<PluginLoadStatus>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
PluginLoadStatus deserialized = JsonSerializer.Deserialize<PluginLoadStatus>(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.Plugins;
|
||||
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.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PluginSettingType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginSettingTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void PluginSettingType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PluginSettingType[] values = Enum.GetValues<PluginSettingType>();
|
||||
|
||||
// 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 (PluginSettingType value in Enum.GetValues<PluginSettingType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
PluginSettingType deserialized = JsonSerializer.Deserialize<PluginSettingType>(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.Primitives;
|
||||
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.Primitives;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ErrorType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ErrorTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void ErrorType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
ErrorType[] values = Enum.GetValues<ErrorType>();
|
||||
|
||||
// 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 (ErrorType value in Enum.GetValues<ErrorType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
ErrorType deserialized = JsonSerializer.Deserialize<ErrorType>(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.VideoLibrary;
|
||||
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.VideoLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="VideoContentType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VideoContentTypeTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void VideoContentType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
VideoContentType[] values = Enum.GetValues<VideoContentType>();
|
||||
|
||||
// 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 (VideoContentType value in Enum.GetValues<VideoContentType>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
VideoContentType deserialized = JsonSerializer.Deserialize<VideoContentType>(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.VideoLibrary;
|
||||
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.VideoLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="VideoRatingSource"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VideoRatingSourceTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void VideoRatingSource_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
VideoRatingSource[] values = Enum.GetValues<VideoRatingSource>();
|
||||
|
||||
// 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 (VideoRatingSource value in Enum.GetValues<VideoRatingSource>())
|
||||
{
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(value, _jsonOptions);
|
||||
VideoRatingSource deserialized = JsonSerializer.Deserialize<VideoRatingSource>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, deserialized);
|
||||
Assert.StartsWith("\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user