Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
ProjectsStatusManagement
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
hasan.bahjat
ProjectsStatusManagement
Commits
3a3ec9b2
Commit
3a3ec9b2
authored
Aug 31, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Tests for dependency and naming convention
parent
1b8283bb
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
326 additions
and
73 deletions
+326
-73
DependencyInjection.cs
PSManagement.Api/DependencyInjection/DependencyInjection.cs
+0
-1
Startup.cs
PSManagement.Api/Startup.cs
+1
-1
ArchitectureApplicationTests.cs
...agement.ArchitectureTests/ArchitectureApplicationTests.cs
+124
-0
ArchitectureDomainTests.cs
PSManagement.ArchitectureTests/ArchitectureDomainTests.cs
+32
-21
ArchitectureInfrastructureServicesTests.cs
...hitectureTests/ArchitectureInfrastructureServicesTests.cs
+0
-34
DependencyTests.cs
PSManagement.ArchitectureTests/DependencyTests.cs
+151
-0
PSManagement.ArchitectureTests.csproj
...t.ArchitectureTests/PSManagement.ArchitectureTests.csproj
+1
-0
DependencyInjection.cs
...t.Presentation/DependencyInjection/DependencyInjection.cs
+5
-4
CustomerMapperConfiguration.cs
...ement.Presentation/Mappers/CustomerMapperConfiguration.cs
+3
-3
EmployeeMapperConfiguration.cs
...ement.Presentation/Mappers/EmployeeMapperConfiguration.cs
+1
-1
MappersConfigurations.cs
PSManagement.Presentation/Mappers/MappersConfigurations.cs
+2
-2
ProjectMapperConfiguration.cs
...gement.Presentation/Mappers/ProjectMapperConfiguration.cs
+6
-6
No files found.
PSManagement.Api/DependencyInjection/DependencyInjection.cs
View file @
3a3ec9b2
...
...
@@ -6,7 +6,6 @@ using System.Reflection;
using
Microsoft.OpenApi.Models
;
using
System
;
using
AutoMapper
;
using
PSManagement.Api.Mappers
;
namespace
PSManagement.Api.DI
{
...
...
PSManagement.Api/Startup.cs
View file @
3a3ec9b2
...
...
@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Mvc;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
PSManagement.Presentaion.DI
;
using
PSManagement.Infrastructure.DI
;
using
PSManagement.Application.DI
;
using
Microsoft.OpenApi.Models
;
...
...
@@ -15,6 +14,7 @@ using System.Linq;
using
System.Threading.Tasks
;
using
PSManagement.Infrastructure.Persistence.DI
;
using
PSManagement.Api.DI
;
using
PSManagement.Presentation.DependencyInjection
;
namespace
PSManagement.Api
{
...
...
PSManagement.ArchitectureTests/ArchitectureApplicationTests.cs
0 → 100644
View file @
3a3ec9b2
using
NetArchTest.Rules
;
using
FluentAssertions
;
using
Xunit
;
using
PSManagement.SharedKernel.CQRS.Command
;
using
PSManagement.SharedKernel.CQRS.Query
;
using
PSManagement.SharedKernel.Events
;
using
PSManagement.SharedKernel.DomainEvents
;
namespace
PSManagement.ArchitectureTests
{
public
partial
class
ArchitectureApplicationTests
:
ArchitectureTest
{
#
region
Events
Handler
Naming
Convention
[
Fact
]
public
void
EventHandler_ShouldHave_NameEndingWith_EventHandler
()
{
var
result
=
Types
.
InAssembly
(
PSManagement
.
Application
.
AssemblyReference
.
Assembly
)
.
That
()
.
ImplementInterface
(
typeof
(
IDomainEventHandler
<>))
.
Should
()
.
HaveNameEndingWith
(
"EventHandler"
)
.
GetResult
();
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Events
Handler
Naming
Convention
#
region
Command
Handler
Naming
Convention
[
Fact
]
public
void
CommandHandlers_ShouldHave_NameEndingWith_CommandHandler
()
{
var
result
=
Types
.
InAssembly
(
PSManagement
.
Application
.
AssemblyReference
.
Assembly
)
.
That
()
.
ImplementInterface
(
typeof
(
ICommandHandler
<,>))
.
Should
()
.
HaveNameEndingWith
(
"CommandHandler"
)
.
GetResult
();
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Command
Handler
Naming
Convention
#
region
Command
Naming
Convention
[
Fact
]
public
void
Commands_ShouldHave_NameEndingWith_Command
()
{
var
result
=
Types
.
InAssembly
(
PSManagement
.
Application
.
AssemblyReference
.
Assembly
)
.
That
()
.
ImplementInterface
(
typeof
(
ICommand
<>))
.
Should
()
.
HaveNameEndingWith
(
"Command"
)
.
GetResult
();
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Command
Naming
Convention
#
region
Query
Handler
Naming
Convention
[
Fact
]
public
void
QueryHandlers_ShouldHave_NameEndingWith_QueryHandler
()
{
var
result
=
Types
.
InAssembly
(
PSManagement
.
Application
.
AssemblyReference
.
Assembly
)
.
That
()
.
ImplementInterface
(
typeof
(
IQueryHandler
<,>))
.
Should
()
.
HaveNameEndingWith
(
"QueryHandler"
)
.
GetResult
();
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Query
Handler
Convention
#
region
Query
Naming
Convention
[
Fact
]
public
void
Queries_ShouldHave_NameEndingWith_Query
()
{
var
result
=
Types
.
InAssembly
(
PSManagement
.
Application
.
AssemblyReference
.
Assembly
)
.
That
()
.
ImplementInterface
(
typeof
(
IQuery
<>))
.
Should
()
.
HaveNameEndingWith
(
"Query"
)
.
GetResult
();
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Query
Convention
#
region
Dummy
Test
//[Fact]
//public void Application_Should_Have_DependOnDomain()
//{
// // Arrange
// var otherProject = new[]
// {
// DomainNamespace
// };
// // Act
// var result = Types
// .InAssembly(Application.AssemblyReference.Assembly)
// .That()
// .HaveNameEndingWith("Handler")
// .Should()
// .HaveDependencyOnAll(otherProject)
// .GetResult();
// // Assert
// result.IsSuccessful.Should().BeTrue();
//}
#
endregion
Dummy
Test
}
}
PSManagement.ArchitectureTests/ArchitectureDomainTests.cs
View file @
3a3ec9b2
using
NetArchTest.Rules
;
using
FluentAssertions
;
using
FluentAssertions
;
using
NetArchTest.Rules
;
using
PSManagement.SharedKernel.Events
;
using
PSManagement.SharedKernel.Repositories
;
using
Xunit
;
namespace
PSManagement.ArchitectureTests
{
public
partial
class
ArchitectureDomainTests
:
ArchitectureTest
public
class
ArchitectureDomainTests
:
ArchitectureTest
{
#
region
Events
Naming
Convention
[
Fact
]
public
void
Domain_Should_Not_DependOnOtherProjec
t
()
public
void
Event_ShouldHave_NameEndingWith_Even
t
()
{
var
result
=
Types
.
InAssembly
(
PSManagement
.
Domain
.
AssemblyReference
.
Assembly
)
.
That
()
.
ImplementInterface
(
typeof
(
IDomainEvent
))
.
Should
()
.
HaveNameEndingWith
(
"Event"
)
.
GetResult
();
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
// Arrange
var
otherProject
=
new
[]
#
endregion
Events
Naming
Convention
#
region
Repository
Naming
Convention
[
Fact
]
public
void
Repositories_ShouldHave_NameEndingWith_Repository
()
{
ApplicationNamespace
,
InfrastructureNamespace
,
PresentationNamespace
,
ApiNamespace
};
// Act
var
result
=
Types
.
InAssembly
(
PSManagement
.
Domain
.
AssemblyReference
.
Assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProject
)
var
result
=
Types
.
InAssembly
(
PSManagement
.
Domain
.
AssemblyReference
.
Assembly
)
.
That
()
.
ImplementInterface
(
typeof
(
IRepository
<>))
.
Should
()
.
HaveNameEndingWith
(
"Repository"
)
.
GetResult
();
// Assert
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Repository
Naming
Convention
}
}
PSManagement.ArchitectureTests/ArchitectureInfrastructureServicesTests.cs
deleted
100644 → 0
View file @
1b8283bb
using
NetArchTest.Rules
;
using
FluentAssertions
;
using
Xunit
;
namespace
PSManagement.ArchitectureTests
{
public
class
ArchitectureInfrastrutureServicesTests
:
ArchitectureTest
{
[
Fact
]
public
void
Services_Should_Not_DependOnOtherProject
()
{
// Arrange
var
otherProject
=
new
[]
{
PresentationNamespace
,
ApiNamespace
,
DataNamespace
};
// Act
var
result
=
Types
.
InAssembly
(
PSManagement
.
Infrastructure
.
Services
.
AssemblyReference
.
Assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProject
)
.
GetResult
();
// Assert
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
}
}
PSManagement.ArchitectureTests/DependencyTests.cs
0 → 100644
View file @
3a3ec9b2
using
NetArchTest.Rules
;
using
FluentAssertions
;
using
Xunit
;
namespace
PSManagement.ArchitectureTests
{
public
class
DependencyTests
:
ArchitectureTest
{
#
region
Presentation
Layer
[
Fact
]
public
void
Presentation_Should_Not_DependOnOtherProjectExceptApplicationAndContracts
()
{
// Arrange
var
otherProject
=
new
[]
{
InfrastructureNamespace
,
DataNamespace
,
DomainNamespace
};
// Act
var
result
=
Types
.
InAssembly
(
Presentation
.
AssemblyReference
.
Assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProject
)
.
GetResult
();
// Assert
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Presentation
Layer
#
region
Application
Layer
[
Fact
]
public
void
Application_Should_Not_DependOnOtherProjectExceptDmain
()
{
// Arrange
var
otherProject
=
new
[]
{
InfrastructureNamespace
,
PresentationNamespace
,
DataNamespace
,
ApiNamespace
};
// Act
var
result
=
Types
.
InAssembly
(
Application
.
AssemblyReference
.
Assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProject
)
.
GetResult
();
// Assert
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Application
Layer
#
region
Domain
Layer
[
Fact
]
public
void
Domain_Should_Not_DependOnOtherProjectExceptSharedKernel
()
{
// Arrange
var
otherProject
=
new
[]
{
ApplicationNamespace
,
InfrastructureNamespace
,
DataNamespace
,
PresentationNamespace
,
ApiNamespace
};
// Act
var
result
=
Types
.
InAssembly
(
PSManagement
.
Domain
.
AssemblyReference
.
Assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProject
)
.
GetResult
();
// Assert
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Domain
Laye
#
region
PersistenceLayer
Layer
[
Fact
]
public
void
Persistence_Should_Not_DependOnOtherProjectExceptDomain
()
{
// Arrange
var
otherProject
=
new
[]
{
ApplicationNamespace
,
InfrastructureNamespace
,
PresentationNamespace
,
ApiNamespace
};
// Act
var
result
=
Types
.
InAssembly
(
PSManagement
.
Infrastructure
.
Persistence
.
AssemblyReference
.
Assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProject
)
.
GetResult
();
// Assert
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Persistence
Layer
#
region
Services
Layer
[
Fact
]
public
void
Services_Should_Not_DependOnOtherProjectExceptApplication
()
{
// Arrange
var
otherProject
=
new
[]
{
PresentationNamespace
,
ApiNamespace
,
DataNamespace
,
DomainNamespace
};
// Act
var
result
=
Types
.
InAssembly
(
PSManagement
.
Infrastructure
.
Services
.
AssemblyReference
.
Assembly
)
.
ShouldNot
()
.
HaveDependencyOnAll
(
otherProject
)
.
GetResult
();
// Assert
result
.
IsSuccessful
.
Should
().
BeTrue
();
}
#
endregion
Services
Layer
}
}
PSManagement.ArchitectureTests/PSManagement.ArchitectureTests.csproj
View file @
3a3ec9b2
...
...
@@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.11.0" />
<PackageReference Include="NetArchTest.Rules" Version="1.3.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
...
...
PSManagement.Presentation/DependencyInjection/DependencyInjection.cs
View file @
3a3ec9b2
using
AutoMapper
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
PSManagement.
Api
.Mappers
;
using
PSManagement.
Presentation
.Mappers
;
namespace
PSManagement.Presenta
ion.DI
namespace
PSManagement.Presenta
tion.DependencyInjection
{
public
static
class
DependencyInjection
{
...
...
@@ -23,7 +23,7 @@ namespace PSManagement.Presentaion.DI
services
.
AddControllers
()
.
AddApplicationPart
(
Presentation
.
AssemblyReference
.
Assembly
);
.
AddApplicationPart
(
AssemblyReference
.
Assembly
);
return
services
;
}
...
...
@@ -35,7 +35,8 @@ namespace PSManagement.Presentaion.DI
services
.
AddScoped
<
Mapper
>();
services
.
AddAutoMapper
(
cfg
=>
{
services
.
AddAutoMapper
(
cfg
=>
{
cfg
.
AddProfile
<
CustomerMapperConfiguration
>();
cfg
.
AddProfile
<
ProjectMapperConfiguration
>();
...
...
PSManagement.Presentation/Mappers/CustomerMapperConfiguration.cs
View file @
3a3ec9b2
...
...
@@ -13,7 +13,7 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
PSManagement.
Api
.Mappers
namespace
PSManagement.
Presentation
.Mappers
{
public
class
CustomerMapperConfiguration
:
Profile
{
...
...
@@ -31,7 +31,7 @@ namespace PSManagement.Api.Mappers
CreateMap
<
IEnumerable
<
CustomerResponse
>,
ListCustomersResponse
>()
.
ConstructUsing
(
src
=>
new
ListCustomersResponse
(
src
));
CreateMap
<
AuthenticationResult
,
AuthenticationResponse
>().
ReverseMap
();
CreateMap
<
AuthenticationResult
,
AuthenticationResponse
>().
ReverseMap
();
}
}
}
PSManagement.Presentation/Mappers/EmployeeMapperConfiguration.cs
View file @
3a3ec9b2
...
...
@@ -3,7 +3,7 @@ using PSManagement.Application.Employees.Common;
using
PSManagement.Application.Projects.Common
;
using
PSManagement.Contracts.Projects.Response
;
namespace
PSManagement.
Api
.Mappers
namespace
PSManagement.
Presentation
.Mappers
{
public
class
EmployeeMapperConfiguration
:
Profile
{
...
...
PSManagement.Presentation/Mappers/MappersConfigurations.cs
View file @
3a3ec9b2
...
...
@@ -5,9 +5,9 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
PSManagement.
Api
.Mappers
namespace
PSManagement.
Presentation
.Mappers
{
public
class
MappersConfigurations
:
Profile
public
class
MappersConfigurations
:
Profile
{
public
MappersConfigurations
()
{
...
...
PSManagement.Presentation/Mappers/ProjectMapperConfiguration.cs
View file @
3a3ec9b2
...
...
@@ -12,7 +12,7 @@ using PSManagement.Contracts.Projects.Requests;
using
PSManagement.Contracts.Projects.Response
;
using
PSManagement.Contracts.Tracks.Response
;
namespace
PSManagement.
Api
.Mappers
namespace
PSManagement.
Presentation
.Mappers
{
public
class
ProjectMapperConfiguration
:
Profile
{
...
...
@@ -25,9 +25,9 @@ namespace PSManagement.Api.Mappers
CreateMap
<
AddProjectStepRequest
,
AddProjectStepCommand
>().
ReverseMap
();
CreateMap
<
ChangeProjectTeamLeaderRequest
,
ChangeProjectTeamLeaderCommand
>().
ReverseMap
();
CreateMap
<
RemoveParticipantRequest
,
RemoveParticipantCommand
>().
ReverseMap
();
CreateMap
<
ProjectDTO
,
ProjectResponse
>().
ReverseMap
();
CreateMap
<
GetProjectsByProjectManagerRequest
,
GetProjectsByFilterQuery
>().
ConstructUsing
(
s
=>
new
GetProjectsByFilterQuery
(
null
,
null
,
null
,
null
,
s
.
ProjectManagerId
,
null
,
null
,
null
)
CreateMap
<
ProjectDTO
,
ProjectResponse
>().
ReverseMap
();
CreateMap
<
GetProjectsByProjectManagerRequest
,
GetProjectsByFilterQuery
>().
ConstructUsing
(
s
=>
new
GetProjectsByFilterQuery
(
null
,
null
,
null
,
null
,
s
.
ProjectManagerId
,
null
,
null
,
null
)
);
...
...
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