Bumped package version to 1.8.5. Added enum route argument converting support. Cleaned up code and added unit test.

This commit is contained in:
2024-07-10 06:37:02 -07:00
parent a698e71e4b
commit 670605ce91
3 changed files with 98 additions and 23 deletions

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using MontoyaTech.Rest.Net;
using Xunit;
namespace Rest.Net.Tests
{
public class RouteArgumentConverterTests
{
public enum TestEnum : long
{
A = 1,
B = 2,
C = 3
}
[Fact]
public static void RouteArgumentConverter_Should_Convert_To_Enum()
{
var converted = RouteArgumentConverter.Convert<TestEnum>("1");
converted.GetType().IsEquivalentTo(typeof(TestEnum)).Should().BeTrue();
converted.Should().Be(TestEnum.A);
}
[Fact]
public static void RouteArgumentConverter_Should_Convert_OutOfRange_To_Enum()
{
var converted = RouteArgumentConverter.Convert<TestEnum>("4");
converted.GetType().IsEquivalentTo(typeof(TestEnum)).Should().BeTrue();
((int)converted).Should().Be(4);
}
}
}