Skip to content

Commit

Permalink
Helper for parsing enums from string
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinM85 committed Jun 27, 2024
1 parent a53a6f6 commit 989149d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Microsoft.Kiota.Abstractions.Tests/EnumHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void EnumGenericIsParsedIfValueIsInteger()
}

[Fact]
public void EnumGenericIsParsedIfValuesAreIntegers()
public void EnumWithFlagsGenericIsParsedIfValuesAreIntegers()
{
var result = EnumHelpers.GetEnumValue<TestEnumWithFlags>("1,2");

Expand All @@ -31,7 +31,7 @@ public void EnumGenericIsParsedIfValueIsString()
}

[Fact]
public void EnumGenericIsParsedIfValuesAreStrings()
public void EnumWithFlagsGenericIsParsedIfValuesAreStrings()
{
var result = EnumHelpers.GetEnumValue<TestEnumWithFlags>("Value1,Value3");

Expand All @@ -47,7 +47,7 @@ public void EnumGenericIsParsedIfValueIsFromEnumMember()
}

[Fact]
public void EnumGenericIsParsedIfValuesAreFromEnumMember()
public void EnumWithFlagsGenericIsParsedIfValuesAreFromEnumMember()
{
var result = EnumHelpers.GetEnumValue<TestEnumWithFlags>("Value__2,Value__3");

Expand All @@ -71,7 +71,7 @@ public void EnumIsParsedIfValueIsInteger()
}

[Fact]
public void EnumIsParsedIfValuesAreIntegers()
public void EnumWithFlagsIsParsedIfValuesAreIntegers()
{
var result = EnumHelpers.GetEnumValue(typeof(TestEnumWithFlags), "1,2");

Expand All @@ -87,7 +87,7 @@ public void EnumIsParsedIfValueIsString()
}

[Fact]
public void EnumIsParsedIfValuesAreStrings()
public void EnumWithFlagsIsParsedIfValuesAreStrings()
{
var result = EnumHelpers.GetEnumValue(typeof(TestEnumWithFlags), "Value1,Value3");

Expand All @@ -103,7 +103,7 @@ public void EnumIsParsedIfValueIsFromEnumMember()
}

[Fact]
public void EnumIsParsedIfValuesAreFromEnumMember()
public void EnumWithFlagsIsParsedIfValuesAreFromEnumMember()
{
var result = EnumHelpers.GetEnumValue(typeof(TestEnumWithFlags), "Value__2,Value__3");

Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/EnumHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ private static ReadOnlySpan<char> ToEnumRawName<T>(ReadOnlySpan<char> span) wher
/// <summary>
/// Gets the enum value from the raw value for the given type
/// </summary>
/// <param name="type"></param>
/// <param name="rawValue"></param>
/// <param name="type">Enum type</param>
/// <param name="rawValue">Raw value</param>
/// <returns></returns>
#if NET5_0_OR_GREATER
public static object? GetEnumValue([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] Type? type, string rawValue)
Expand Down

0 comments on commit 989149d

Please sign in to comment.