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:
41
Rest.Net.Tests/RouteArgumentConverterTests.cs
Normal file
41
Rest.Net.Tests/RouteArgumentConverterTests.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user