forked from opensearch-project/opensearch-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for
IEnumerable<int?>
property mapping (opensearch-project#503)
Fixes opensearch-project#380 Signed-off-by: Kostas <[email protected]>
- Loading branch information
1 parent
4e721ee
commit afa7c7c
Showing
3 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using OpenSearch.Client; | ||
using OpenSearch.OpenSearch.Xunit.XunitPlumbing; | ||
|
||
namespace Tests.Mapping | ||
{ | ||
public class PropertyWalkerTests | ||
{ | ||
[U] | ||
public void BoolGetsMappedCorrectly() | ||
{ | ||
var result = TestPropertyType<bool>(); | ||
result.Should().Be("boolean"); | ||
} | ||
|
||
[U] | ||
public void StringGetsMappedCorrectly() | ||
{ | ||
var result = TestPropertyType<string>(); | ||
result.Should().Be("text"); | ||
} | ||
|
||
|
||
[U] | ||
public void DateTimeGetsMappedCorrectly() | ||
{ | ||
var result = TestPropertyType<DateTime>(); | ||
result.Should().Be("date"); | ||
} | ||
|
||
[U] | ||
public void IEnumerableOfNullableGetsMappedCorrectly() | ||
{ | ||
var result = TestPropertyType<IEnumerable<int?>>(); | ||
result.Should().Be("integer"); | ||
} | ||
|
||
[U] | ||
public void IListOfNullableGetsMappedCorrectly() | ||
{ | ||
var result = TestPropertyType<IList<int?>>(); | ||
result.Should().Be("integer"); | ||
} | ||
|
||
[U] | ||
public void IEnumerableOfValueTypesGetsMappedCorrectly() | ||
{ | ||
var result = TestPropertyType<IEnumerable<int>>(); | ||
result.Should().Be("integer"); | ||
} | ||
|
||
[U] | ||
public void IListOfValueTypesGetsMappedCorrectly() | ||
{ | ||
var result = TestPropertyType<IList<int>>(); | ||
result.Should().Be("integer"); | ||
} | ||
|
||
private static string TestPropertyType<T>() | ||
{ | ||
var walker = new PropertyWalker(typeof(Test<T>), null, 0); | ||
var properties = walker.GetProperties(); | ||
var result = properties.SingleOrDefault(); | ||
return result.Value?.Type; | ||
} | ||
|
||
|
||
private class Test<T> | ||
{ | ||
public T Values { get; set; } | ||
} | ||
|
||
} | ||
} |