Initial curated itworx-knowledge-hub source from 3b1751d0d9dee551aa6994eee0093704dc334817
This commit is contained in:
commit
ad8ad252a9
825 files changed
+124216
No files matched your search
@@ -0,0 +1 @@
|
||||
global using Xunit;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="xunit" />
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ItWorx.KnowledgeHub.Architecture.Tests;
|
||||
|
||||
public sealed class ProjectReferenceTests
|
||||
{
|
||||
[Fact]
|
||||
public void Domain_and_contracts_have_no_project_dependencies()
|
||||
{
|
||||
Assert.Empty(ReadProjectReferences("src/backend/ItWorx.KnowledgeHub.Domain/ItWorx.KnowledgeHub.Domain.csproj"));
|
||||
Assert.Empty(ReadProjectReferences("src/backend/ItWorx.KnowledgeHub.Contracts/ItWorx.KnowledgeHub.Contracts.csproj"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Application_depends_only_on_domain_and_contracts()
|
||||
{
|
||||
var references = ReadProjectReferences(
|
||||
"src/backend/ItWorx.KnowledgeHub.Application/ItWorx.KnowledgeHub.Application.csproj");
|
||||
|
||||
Assert.Equal(
|
||||
new[]
|
||||
{
|
||||
"ItWorx.KnowledgeHub.Contracts",
|
||||
"ItWorx.KnowledgeHub.Domain"
|
||||
},
|
||||
references.Order(StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Infrastructure_does_not_depend_on_api()
|
||||
{
|
||||
var references = ReadProjectReferences(
|
||||
"src/backend/ItWorx.KnowledgeHub.Infrastructure/ItWorx.KnowledgeHub.Infrastructure.csproj");
|
||||
|
||||
Assert.DoesNotContain("ItWorx.KnowledgeHub.Api", references);
|
||||
}
|
||||
|
||||
private static IReadOnlyCollection<string> ReadProjectReferences(string relativeProjectPath)
|
||||
{
|
||||
var repositoryRoot = FindRepositoryRoot();
|
||||
var projectPath = Path.Combine(
|
||||
repositoryRoot.FullName,
|
||||
relativeProjectPath.Replace('/', Path.DirectorySeparatorChar));
|
||||
|
||||
var document = XDocument.Load(projectPath);
|
||||
return document
|
||||
.Descendants("ProjectReference")
|
||||
.Select(element => element.Attribute("Include")?.Value)
|
||||
.Where(value => !string.IsNullOrWhiteSpace(value))
|
||||
.Select(value => Path.GetFileNameWithoutExtension(value!))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static DirectoryInfo FindRepositoryRoot()
|
||||
{
|
||||
DirectoryInfo? current = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
|
||||
while (current is not null)
|
||||
{
|
||||
if (File.Exists(Path.Combine(current.FullName, "global.json"))
|
||||
&& (File.Exists(Path.Combine(current.FullName, "CLAUDE.md"))
|
||||
|| File.Exists(Path.Combine(current.FullName, "PUBLIC_SOURCE_EXPORT.md"))))
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
current = current.Parent;
|
||||
}
|
||||
|
||||
throw new DirectoryNotFoundException("Could not locate the repository root.");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user