-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add IContentComponent to C&S contents
tests: add FooterLinkTagHelper changes unit tests chore: Linted code for plan-technology-for-your-school.sln solution chore: sonarcloud fix chore: add .sonarqube to gitignore fix: handle prefixed "/" chore formatting fix: expected url fix: expected url fix: test fix: Look in all assemblies for IContentComponent types wip chore: add text fix: unit tests, tweak validation fix(redis): Handle serialisation of IContentComponent properties chore: formatting fix: handle redisc onnection failures better fix tests fixes + refactor
- Loading branch information
1 parent
cf8ba9f
commit 15fbc03
Showing
6 changed files
with
65 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
using System.Reflection; | ||
|
||
namespace Dfe.PlanTech.Domain.Helpers; | ||
|
||
public static class ReflectionHelpers | ||
{ | ||
public static IEnumerable<Type> GetTypesInheritingFrom<TBase>() | ||
{ | ||
var baseType = typeof(TBase); | ||
|
||
return AppDomain.CurrentDomain.GetAssemblies() | ||
.SelectMany((assembley) => assembley.GetTypes()) | ||
.Where((type) => baseType.IsAssignableFrom(type) && type != baseType); | ||
} | ||
public static IEnumerable<Type> GetTypesInheritingFrom<TBase>() => GetTypesInheritingFrom(typeof(TBase)); | ||
|
||
public static IEnumerable<Type> GetTypesInheritingFrom(Type baseType, bool internalProjectsOnly = true) => AppDomain.CurrentDomain.GetAssemblies() | ||
.Where(assembly => IsNotTestProject(assembly, internalProjectsOnly)) | ||
.SelectMany(AssemblyTypes) | ||
.Where(InheritsBaseType(baseType)); | ||
|
||
private static Func<Type, bool> InheritsBaseType(Type baseType) => (type) => baseType.IsAssignableFrom(type) && type != baseType; | ||
|
||
private static Type[] AssemblyTypes(Assembly assembly) => assembly.GetTypes(); | ||
|
||
private static bool IsNotTestProject(Assembly assembly, bool internalProjectsOnly) | ||
=> assembly.FullName != null && !assembly.FullName.Contains("Test") && (!internalProjectsOnly || assembly.FullName.Contains("Dfe.PlanTech.")); | ||
|
||
public static bool HasParameterlessConstructor(this Type type) => type.GetConstructor(Type.EmptyTypes) != null || type.GetConstructors().Length == 0; | ||
|
||
public static bool IsConcreteClass(this Type type) => !type.IsAbstract && !type.IsInterface; | ||
} |
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
14 changes: 9 additions & 5 deletions
14
tests/Dfe.PlanTech.Infrastructure.Redis.UnitTests/ContentComponentJsonExtensionsTests.cs
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
Empty file removed
0
tests/Dfe.PlanTech.Infrastructure.Redis.UnitTests/RedisConnectionManagerTests.cs
Empty file.