Skip to content

Commit

Permalink
Fix bug and improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
skrysmanski committed Apr 30, 2024
1 parent f141ecf commit d8e3e0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/AppMotor.Core/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ public static bool Is(this Type typeToCheck, Type baseOrInterfaceType)

baseType = baseType.BaseType;
}

return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
// Copyright AppMotor Framework (https://github.com/skrysmanski/AppMotor)

using System.Collections;
using System.Numerics;
using System.Reflection;

Expand Down Expand Up @@ -190,13 +189,17 @@ public void Test_Is_OpenGeneric()
typeof(List<>).Is(typeof(IReadOnlyCollection<string>)).ShouldBe(false);
typeof(List<>).Is(typeof(object)).ShouldBe(true);
typeof(List<>).Is(typeof(int)).ShouldBe(false);
typeof(List<int>).Is(typeof(GenericClassA<>)).ShouldBe(false);

typeof(GenericClassB<int, string>).Is(typeof(IGenericTestInterface<>)).ShouldBe(true);
typeof(GenericClassB<int, string>).Is(typeof(GenericClassA<>)).ShouldBe(true);
typeof(GenericClassC<int, string>).Is(typeof(GenericClassA<>)).ShouldBe(true);

typeof(IGenericTestInterface<>).Is(typeof(object)).ShouldBe(true);

typeof(GenericStructA<string>).Is(typeof(IGenericTestInterface<>)).ShouldBe(true);

typeof(MultiIEnumerableTestClass).Is(typeof(IEnumerable<>)).ShouldBe(true);
}

private interface ITestInterface;
Expand All @@ -221,6 +224,9 @@ private class GenericClassB<TValue1, TValue2> : GenericClassA<TValue1>, IGeneric
public void DoSomething(TValue2 value) => throw new NotSupportedException();
}

// For code coverage purposes
private class GenericClassC<TValue1, TValue2> : GenericClassB<TValue1, TValue2>;

private struct GenericStructA<TValue> : IGenericTestInterface<TValue>
{
public void DoSomething(TValue value) => throw new NotSupportedException();
Expand Down

0 comments on commit d8e3e0d

Please sign in to comment.