mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-09-29 15:30:50 -04:00
Co-authored-by: DieselTech <30128380+DieselTech@users.noreply.github.com> Co-authored-by: majora2007 <josephmajora@gmail.com>
23 lines
590 B
C#
23 lines
590 B
C#
#nullable enable
|
|
using System;
|
|
using API.Entities.Enums;
|
|
using API.Extensions;
|
|
using Xunit;
|
|
|
|
namespace API.Tests.Extensions;
|
|
|
|
public class EnumExtensionTests
|
|
{
|
|
|
|
[Theory]
|
|
[InlineData("Early Childhood", AgeRating.EarlyChildhood, true)]
|
|
[InlineData("M", AgeRating.Mature, true)]
|
|
[InlineData("ThisIsNotAnAgeRating", default(AgeRating), false)]
|
|
public void TryParse<TEnum>(string? value, TEnum expected, bool success) where TEnum : struct, Enum
|
|
{
|
|
Assert.Equal(EnumExtensions.TryParse(value, out TEnum got), success);
|
|
Assert.Equal(expected, got);
|
|
}
|
|
|
|
}
|