Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
HIAST-Clinics
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
almohanad.hafez
HIAST-Clinics
Commits
beead90c
Commit
beead90c
authored
Aug 27, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add architecture tests
parent
03d7bc2d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
218 additions
and
1 deletion
+218
-1
ArchitectureTests.cs
Clinics.Backend/ArchitectureTests/ArchitectureTests.cs
+168
-0
ArchitectureTests.csproj
Clinics.Backend/ArchitectureTests/ArchitectureTests.csproj
+31
-0
Clinics.Backend.sln
Clinics.Backend/Clinics.Backend.sln
+10
-1
AssemblyReference.cs
Clinics.Backend/Domain/AssemblyReference.cs
+9
-0
No files found.
Clinics.Backend/ArchitectureTests/ArchitectureTests.cs
0 → 100644
View file @
beead90c
using
FluentAssertions
;
using
NetArchTest.Rules
;
using
Xunit
;
namespace
ArchitectureTests
;
public
class
ArchitectureTests
{
private
const
string
DomainNamespace
=
"Domain"
;
private
const
string
ApplicationNamespace
=
"Application"
;
private
const
string
InfrastructureNamespace
=
"Infrastructure"
;
private
const
string
PersistenceNamespace
=
"Persistence"
;
private
const
string
PresentationNamespace
=
"Presenttation"
;
private
const
string
APINamespace
=
"API"
;
// Use this naming convension
// .._Should_[Not]_...()
[
Fact
]
public
void
Domain_Should_Not_HaveDependencyOnOtherProjects
()
{
#
region
Arrange
var
assembly
=
Domain
.
AssemblyReference
.
Assembly
;
var
otherProjects
=
new
[]
{
ApplicationNamespace
,
InfrastructureNamespace
,
PersistenceNamespace
,
PresentationNamespace
,
APINamespace
};
#
endregion
#
region
Act
var
testResult
=
Types
.
InAssembly
(
assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProjects
)
.
GetResult
();
#
endregion
#
region
Assert
testResult
.
IsSuccessful
.
Should
().
BeTrue
();
#
endregion
}
[
Fact
]
public
void
Application_Should_Not_HaveDependencyOnOtherProjects
()
{
#
region
Arrange
var
assembly
=
Application
.
AssemblyReference
.
Assembly
;
var
otherProjects
=
new
[]
{
InfrastructureNamespace
,
PersistenceNamespace
,
PresentationNamespace
,
APINamespace
};
#
endregion
#
region
Act
var
testResult
=
Types
.
InAssembly
(
assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProjects
)
.
GetResult
();
#
endregion
#
region
Assert
testResult
.
IsSuccessful
.
Should
().
BeTrue
();
#
endregion
}
[
Fact
]
public
void
Infrastructure_Should_Not_HaveDependencyOnPresentation
()
{
#
region
Arrange
var
assembly
=
Infrastructure
.
AssemblyReference
.
Assembly
;
var
otherProjects
=
new
[]
{
PersistenceNamespace
,
PresentationNamespace
,
APINamespace
};
#
endregion
#
region
Act
var
testResult
=
Types
.
InAssembly
(
assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProjects
)
.
GetResult
();
#
endregion
#
region
Assert
testResult
.
IsSuccessful
.
Should
().
BeTrue
();
#
endregion
}
[
Fact
]
public
void
Persistence_Should_Not_HaveDependencyOnPresentation
()
{
#
region
Arrange
var
assembly
=
Persistence
.
AssemblyReference
.
Assembly
;
var
otherProjects
=
new
[]
{
InfrastructureNamespace
,
PresentationNamespace
,
APINamespace
};
#
endregion
#
region
Act
var
testResult
=
Types
.
InAssembly
(
assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProjects
)
.
GetResult
();
#
endregion
#
region
Assert
testResult
.
IsSuccessful
.
Should
().
BeTrue
();
#
endregion
}
[
Fact
]
public
void
Presentation_Should_Not_HaveDependencyOnInfrastructure
()
{
#
region
Arrange
var
assembly
=
Presentation
.
AssemblyReference
.
Assembly
;
var
otherProjects
=
new
[]
{
InfrastructureNamespace
,
PersistenceNamespace
,
APINamespace
};
#
endregion
#
region
Act
var
testResult
=
Types
.
InAssembly
(
assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProjects
)
.
GetResult
();
#
endregion
#
region
Assert
testResult
.
IsSuccessful
.
Should
().
BeTrue
();
#
endregion
}
}
Clinics.Backend/ArchitectureTests/ArchitectureTests.csproj
0 → 100644
View file @
beead90c
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="NetArchTest.Rules" Version="1.3.2" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit.extensibility.core" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\API\API.csproj" />
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\Persistence\Persistence.csproj" />
<ProjectReference Include="..\Presentation\Presentation.csproj" />
</ItemGroup>
</Project>
Clinics.Backend/Clinics.Backend.sln
View file @
beead90c
...
@@ -21,7 +21,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "Persistence\
...
@@ -21,7 +21,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "Persistence\
EndProject
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "API\API.csproj", "{15B2AA13-EBBD-408B-A4B3-4BAB43D74267}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "API\API.csproj", "{15B2AA13-EBBD-408B-A4B3-4BAB43D74267}"
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{4EB41743-695F-4822-87F6-E6F9B48A8E6B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{4EB41743-695F-4822-87F6-E6F9B48A8E6B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{05E390C6-AFE5-42FB-A3E2-CEEE1E6A75EE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchitectureTests", "ArchitectureTests\ArchitectureTests.csproj", "{07C6D0DB-7181-4E6F-9BC1-863FCDAD9490}"
EndProject
EndProject
Global
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
@@ -53,6 +57,10 @@ Global
...
@@ -53,6 +57,10 @@ Global
{4EB41743-695F-4822-87F6-E6F9B48A8E6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EB41743-695F-4822-87F6-E6F9B48A8E6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EB41743-695F-4822-87F6-E6F9B48A8E6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EB41743-695F-4822-87F6-E6F9B48A8E6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EB41743-695F-4822-87F6-E6F9B48A8E6B}.Release|Any CPU.Build.0 = Release|Any CPU
{4EB41743-695F-4822-87F6-E6F9B48A8E6B}.Release|Any CPU.Build.0 = Release|Any CPU
{07C6D0DB-7181-4E6F-9BC1-863FCDAD9490}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07C6D0DB-7181-4E6F-9BC1-863FCDAD9490}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07C6D0DB-7181-4E6F-9BC1-863FCDAD9490}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07C6D0DB-7181-4E6F-9BC1-863FCDAD9490}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
HideSolutionNode = FALSE
...
@@ -66,6 +74,7 @@ Global
...
@@ -66,6 +74,7 @@ Global
{D04C0D6C-3FC9-4359-A017-DFCFA1475639} = {878AE2C9-3E34-4332-ACC0-E6B601085710}
{D04C0D6C-3FC9-4359-A017-DFCFA1475639} = {878AE2C9-3E34-4332-ACC0-E6B601085710}
{2B5111ED-7AB8-46E2-90F8-AF0C70265618} = {FDA56BCD-A53D-4BA1-A59D-3F44FA32DDD7}
{2B5111ED-7AB8-46E2-90F8-AF0C70265618} = {FDA56BCD-A53D-4BA1-A59D-3F44FA32DDD7}
{4EB41743-695F-4822-87F6-E6F9B48A8E6B} = {FDA56BCD-A53D-4BA1-A59D-3F44FA32DDD7}
{4EB41743-695F-4822-87F6-E6F9B48A8E6B} = {FDA56BCD-A53D-4BA1-A59D-3F44FA32DDD7}
{07C6D0DB-7181-4E6F-9BC1-863FCDAD9490} = {05E390C6-AFE5-42FB-A3E2-CEEE1E6A75EE}
EndGlobalSection
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E9FC9252-1283-485F-8F84-3574CFA12633}
SolutionGuid = {E9FC9252-1283-485F-8F84-3574CFA12633}
...
...
Clinics.Backend/Domain/AssemblyReference.cs
0 → 100644
View file @
beead90c
using
System.Reflection
;
namespace
Domain
;
public
class
AssemblyReference
{
public
static
readonly
Assembly
Assembly
=
typeof
(
AssemblyReference
).
Assembly
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment