Removes the redundant null guards from the metadata value objects

This commit is contained in:
BinaryAlley committed 2026-09-26 17:54:22 +03:00
1 parent ef913f5c9e
commit 7534155f0e
4 files changed
+2 -42

No files matched your search

@@ -1,7 +1,6 @@
#region ========================================================================= USING ===================================================================================== #region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core; using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives; using Lumina.Domain.Common.Primitives;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
#endregion #endregion
@@ -68,7 +67,6 @@ public abstract class BaseMetadata : ValueObject
/// <param name="tags">The list of tags of the element to which this metadata object belongs to.</param> /// <param name="tags">The list of tags of the element to which this metadata object belongs to.</param>
/// <param name="language">The optional language of the element to which this metadata object belongs to, if applicable.</param> /// <param name="language">The optional language of the element to which this metadata object belongs to, if applicable.</param>
/// <param name="originalLanguage">The optional original language of the element to which this metadata object belongs to, if applicable.</param> /// <param name="originalLanguage">The optional original language of the element to which this metadata object belongs to, if applicable.</param>
/// <exception cref="ArgumentNullException">Thrown when the <see cref="title"/> value is <see langword="null"/></exception>
protected BaseMetadata( protected BaseMetadata(
string title, string title,
Optional<string> originalTitle, Optional<string> originalTitle,
@@ -79,7 +77,7 @@ public abstract class BaseMetadata : ValueObject
Optional<LanguageInfo> language, Optional<LanguageInfo> language,
Optional<LanguageInfo> originalLanguage) Optional<LanguageInfo> originalLanguage)
{ {
Title = title ?? throw new ArgumentNullException(nameof(title)); Title = title;
OriginalTitle = originalTitle; OriginalTitle = originalTitle;
Description = description; Description = description;
ReleaseInfo = releaseInfo; ReleaseInfo = releaseInfo;
@@ -1,7 +1,6 @@
#region ========================================================================= USING ===================================================================================== #region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives; using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata; using Lumina.Domain.Common.ValueObjects.Metadata;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
#endregion #endregion
@@ -72,7 +71,7 @@ public class VideoMetadata : BaseMetadata
: base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage) : base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage)
{ {
DurationInSeconds = durationInSeconds; DurationInSeconds = durationInSeconds;
Resolution = resolution ?? throw new ArgumentNullException(nameof(resolution)); Resolution = resolution;
FrameRate = frameRate; FrameRate = frameRate;
VideoCodec = videoCodec; VideoCodec = videoCodec;
AudioCodec = audioCodec; AudioCodec = audioCodec;
@@ -2,7 +2,6 @@
using Lumina.Domain.Common.Primitives; using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata; using Lumina.Domain.Common.ValueObjects.Metadata;
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata; using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endregion #endregion
@@ -51,21 +50,6 @@ public class BaseMetadataTests
Assert.False(metadata.OriginalLanguage.HasValue); Assert.False(metadata.OriginalLanguage.HasValue);
} }
[Fact]
public void Constructor_WhenTitleIsNull_ShouldThrowArgumentNullException()
{
// Act & Assert
Assert.Throws<ArgumentNullException>(() => new TestMetadata(
null!,
Optional<string>.None(),
Optional<string>.None(),
_releaseInfoFixture.Create(),
[],
[],
Optional<LanguageInfo>.None(),
Optional<LanguageInfo>.None()));
}
[Fact] [Fact]
public void Equals_WithSameData_ShouldReturnTrue() public void Equals_WithSameData_ShouldReturnTrue()
{ {
@@ -4,7 +4,6 @@ using Lumina.Domain.Common.ValueObjects.Metadata;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects; using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata; using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
using Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects; using Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
#endregion #endregion
@@ -58,26 +57,6 @@ public class VideoMetadataTests
Assert.False(result.Value.OriginalLanguage.HasValue); Assert.False(result.Value.OriginalLanguage.HasValue);
} }
[Fact]
public void Create_WhenResolutionIsNull_ShouldThrowArgumentNullException()
{
// Act & Assert
Assert.Throws<ArgumentNullException>(() => VideoMetadata.Create(
"Inception",
Optional<string>.None(),
durationInSeconds: 8880,
null!,
Optional<string>.None(),
_releaseInfoFixture.Create(),
Optional<LanguageInfo>.None(),
Optional<LanguageInfo>.None(),
Optional<float>.None(),
Optional<string>.None(),
Optional<string>.None(),
[],
[]));
}
[Fact] [Fact]
public void Equals_WithSameValues_ShouldReturnTrue() public void Equals_WithSameValues_ShouldReturnTrue()
{ {