Skip to content

Commit

Permalink
LazyEnumParse tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Feb 22, 2023
1 parent c9b78f5 commit 472b163
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<h3 align="center">

![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=feature/dc)
![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=develop)
[![NuGet](https://img.shields.io/nuget/vpre/DotNetStac)](https://www.nuget.org/packages/DotNetStac/)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/feature/dc/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/develop/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![Gitter](https://img.shields.io/gitter/room/SpatioTemporal-Asset-Catalog/Lobby?color=yellow)](https://gitter.im/SpatioTemporal-Asset-Catalog/Lobby)
[![License](https://img.shields.io/badge/license-AGPL3-blue.svg)](LICENSE)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Terradue/DotNetStac/master?filepath=example.ipynb)
Expand Down
30 changes: 30 additions & 0 deletions src/DotNetStac.Test/Common/Enum/Enum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace Stac.Test.Common
{
public enum Enum1
{
test,

summary
}

public enum Enum2
{
[JsonProperty("test")]
Test,

[JsonProperty("summary")]
Summary
}

public enum Enum3
{
[EnumMember(Value = @"cql2-text")]
Cql2Text,

[EnumMember(Value = @"cql2-json")]
Cql2Json
}
}
17 changes: 16 additions & 1 deletion src/DotNetStac.Test/Common/StacAccessorsHelpersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Stac.Common;
using Xunit;

namespace Stac.Test.Item
namespace Stac.Test.Common
{
public class StacAccessorsHelpersTests : TestBase
{
Expand Down Expand Up @@ -73,5 +73,20 @@ public void GetPropertyTest()
Assert.Equal(summaryItemType, item.GetProperty<SummaryItemType>("summary"));

}

[Fact]
public void LazyEnumParseTests()
{
Enum1 test = Enum1.test;
Assert.Equal(test, StacAccessorsHelpers.LazyEnumParse(typeof(Enum1), "test"));

Enum2 test2 = Enum2.Test;
Assert.Equal(test2, StacAccessorsHelpers.LazyEnumParse(typeof(Enum2), "test"));

Enum3 test3 = Enum3.Cql2Json;
Assert.Equal(test3, StacAccessorsHelpers.LazyEnumParse(typeof(Enum3), "cql2-json"));

Assert.Equal(test3, StacAccessorsHelpers.LazyEnumParse(typeof(Enum3), "Cql2Json"));
}
}
}

0 comments on commit 472b163

Please sign in to comment.