Browse Source

Add test for TypeHelper and improve ReflectionHelper

pull/3193/head
Halil İbrahim Kalkan 6 years ago
parent
commit
a628e177a5
  1. 4
      framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs
  2. 21
      framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/TypeHelper_Tests.cs

4
framework/src/Volo.Abp.Core/Volo/Abp/Reflection/ReflectionHelper.cs

@ -53,14 +53,14 @@ namespace Volo.Abp.Reflection
if (givenTypeInfo.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)
{
result.Add(givenType);
result.AddIfNotContains(givenType);
}
foreach (var interfaceType in givenTypeInfo.GetInterfaces())
{
if (interfaceType.GetTypeInfo().IsGenericType && interfaceType.GetGenericTypeDefinition() == genericType)
{
result.Add(interfaceType);
result.AddIfNotContains(interfaceType);
}
}

21
framework/test/Volo.Abp.Core.Tests/Volo/Abp/Reflection/TypeHelper_Tests.cs

@ -16,6 +16,27 @@ namespace Volo.Abp.Reflection
guidType.ShouldBe(typeof(Guid));
}
[Fact]
public void IsEnumerable()
{
TypeHelper.IsEnumerable(
typeof(IEnumerable<string>),
out var itemType
).ShouldBeTrue();
itemType.ShouldBe(typeof(string));
TypeHelper.IsEnumerable(
typeof(List<TypeHelper_Tests>),
out itemType
).ShouldBeTrue();
itemType.ShouldBe(typeof(TypeHelper_Tests));
TypeHelper.IsEnumerable(
typeof(TypeHelper_Tests),
out itemType
).ShouldBeFalse();
}
[Fact]
public void IsDictionary()
{

Loading…
Cancel
Save