#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.UnitTests.Common.ValueObjects.Metadata;
///
/// Contains unit tests for the class.
///
[ExcludeFromCodeCoverage]
public class RatingTests
{
[Fact]
public void Constructor_WhenCalled_ShouldSetValueMaxValueAndVoteCount()
{
// Act
TestRating rating = new(value: 4.5m, maxValue: 5, voteCount: Optional.Some(100));
// Assert
Assert.Equal(4.5m, rating.Value);
Assert.Equal(5, rating.MaxValue);
Assert.True(rating.VoteCount.HasValue);
Assert.Equal(100, rating.VoteCount.Value);
}
[Fact]
public void AsPercentage_WhenCalled_ShouldReturnValueAsPercentageOfMaxValue()
{
// Arrange
TestRating rating = new(value: 4.5m, maxValue: 5, voteCount: Optional.None());
// Act
decimal result = rating.AsPercentage();
// Assert
Assert.Equal(90, result);
}
[Fact]
public void AsPercentage_WhenValueEqualsMaxValue_ShouldReturnOneHundred()
{
// Arrange
TestRating rating = new(value: 5, maxValue: 5, voteCount: Optional.None());
// Act
decimal result = rating.AsPercentage();
// Assert
Assert.Equal(100, result);
}
///
/// Concrete test implementation of the abstract class.
///
private sealed class TestRating : Rating
{
///
/// Initializes a new instance of the class.
///
/// The numeric value of the rating.
/// The maximum possible rating value.
/// The optional number of votes or reviews.
public TestRating(decimal value, decimal maxValue, Optional voteCount) : base(value, maxValue, voteCount)
{
}
///
/// Gets the list of items that define equality of the object.
///
/// A list of items defining the equality.
public override IEnumerable