Skip to content

Commit 98b8960

Browse files
committed
Add tests for directory structure
1 parent 669943d commit 98b8960

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Reflection;
2+
using FluentAssertions;
3+
using RealTimeWeatherMonitoringApp.Application.Interfaces;
4+
using RealTimeWeatherMonitoringApp.Presentation.Utility;
5+
using Xunit;
6+
7+
namespace RealTimeWeatherMonitoringTest.Presentation;
8+
9+
public class DirectoryStructureShould
10+
{
11+
[Fact]
12+
public void IParsingStrategyImplementations_ResideInParsersDirectory()
13+
{
14+
foreach (var type in GetImplementationsOfGenericInterface(typeof(IParsingStrategy<>)))
15+
{
16+
type.Namespace.Should().NotBeNull()
17+
.And.StartWith(Configuration.ParsersNamespace,
18+
"because all IParsingStrategy implementations should reside in the Parsers directory");
19+
}
20+
}
21+
22+
private static IEnumerable<Type> GetImplementationsOfGenericInterface(Type genericInterfaceType)
23+
{
24+
return Assembly.GetAssembly(genericInterfaceType)!.GetTypes()
25+
.Where(t => !t.IsAbstract && t.GetInterfaces()
26+
.Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == genericInterfaceType));
27+
}
28+
}

0 commit comments

Comments
 (0)