This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6e14be
commit 8e1c797
Showing
7 changed files
with
352 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using RookieShop.Application; | ||
|
||
namespace RookieShop.ArchTests; | ||
|
||
public sealed class ApplicationLayerTest | ||
{ | ||
[Fact] | ||
public void Application_Should_HaveDependencyOnDomain() | ||
{ | ||
// Arrange | ||
var applicationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(applicationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Application)) | ||
.Should() | ||
.HaveDependencyOn(nameof(Domain)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Application_Should_HaveDependencyOnInfrastructure() | ||
{ | ||
// Arrange | ||
var applicationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(applicationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Application)) | ||
.Should() | ||
.HaveDependencyOn(nameof(Infrastructure)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Application_Should_HaveNotDependencyOnPersistence() | ||
{ | ||
// Arrange | ||
var applicationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(applicationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Application)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(Persistence)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Application_Should_HaveNotDependencyOnApiService() | ||
{ | ||
// Arrange | ||
var applicationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(applicationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Application)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(ApiService)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System.Reflection; | ||
using RookieShop.Domain; | ||
using RookieShop.Domain.SeedWork; | ||
|
||
namespace RookieShop.ArchTests; | ||
|
||
public sealed class DomainLayerTest | ||
{ | ||
[Fact] | ||
public void DomainLayer_Should_BeSealed() | ||
{ | ||
// Arrange | ||
var assembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(assembly) | ||
.That() | ||
.AreNotNestedPrivate() | ||
.And() | ||
.HaveNameEndingWith(nameof(Domain)) | ||
.Should() | ||
.BeSealed() | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Entities_Should_HavePublicParameterlessConstructor() | ||
{ | ||
// Arrange | ||
var entityType = Types.InAssembly(AssemblyReference.Assembly) | ||
.That() | ||
.Inherit(typeof(EntityBase)) | ||
.GetTypes(); | ||
|
||
// Act | ||
var failingTypes = entityType.Where(type => | ||
Array.Find(type.GetConstructors(BindingFlags.Public | BindingFlags.Instance), | ||
c => c.GetParameters().Length == 0) is null | ||
).ToList(); | ||
|
||
// Assert | ||
failingTypes.Should().BeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void Domain_Should_NotHaveDependencyOnApplication() | ||
{ | ||
// Arrange | ||
var domainAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(domainAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Domain)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(Application)) | ||
.GetResult(); | ||
|
||
// Assert | ||
result.IsSuccessful.Should().BeTrue(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using RookieShop.Infrastructure; | ||
|
||
namespace RookieShop.ArchTests; | ||
|
||
public sealed class InfrastructureLayerTest | ||
{ | ||
[Fact] | ||
public void Infrastructure_Should_HaveDependencyOnDomain() | ||
{ | ||
// Arrange | ||
var infrastructureAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(infrastructureAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Infrastructure)) | ||
.Should() | ||
.HaveDependencyOn(nameof(Domain)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Infrastructure_Should_HaveNotDependencyOnPersistence() | ||
{ | ||
// Arrange | ||
var infrastructureAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(infrastructureAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Infrastructure)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(Persistence)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using RookieShop.Persistence; | ||
|
||
namespace RookieShop.ArchTests; | ||
|
||
public sealed class PersistenceLayerTest | ||
{ | ||
[Fact] | ||
public void Persistence_Should_HaveDependencyOnDomain() | ||
{ | ||
// Arrange | ||
var persistenceAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(persistenceAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Persistence)) | ||
.Should() | ||
.HaveDependencyOn(nameof(Domain)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Persistence_Should_HaveDependencyOnInfrastructure() | ||
{ | ||
// Arrange | ||
var persistenceAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(persistenceAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Persistence)) | ||
.Should() | ||
.HaveDependencyOn(nameof(Infrastructure)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Persistence_Should_HaveNotDependencyOnApplication() | ||
{ | ||
// Arrange | ||
var persistenceAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(persistenceAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(Persistence)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(Application)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void ApplicationDbContext_Should_HaveBeInPersistenceLayer() | ||
{ | ||
// Arrange | ||
var assembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types | ||
.InAssembly(assembly) | ||
.That() | ||
.ResideInNamespace(nameof(Persistence)) | ||
.Should() | ||
.HaveName(nameof(ApplicationDbContext)) | ||
.GetResult(); | ||
|
||
// Assert | ||
result.IsSuccessful.Should().BeTrue(result.ToString()); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using RookieShop.ApiService; | ||
|
||
namespace RookieShop.ArchTests; | ||
|
||
public sealed class PresentationLayerTest | ||
{ | ||
[Fact] | ||
public void Presentation_Should_HaveDependencyOnApplication() | ||
{ | ||
// Arrange | ||
var presentationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(presentationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(ApiService)) | ||
.Should() | ||
.HaveDependencyOn(nameof(Application)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Presentation_Should_HaveNotDependencyOnDomain() | ||
{ | ||
// Arrange | ||
var presentationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(presentationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(ApiService)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(Domain)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Presentation_Should_HaveNotDependencyOnInfrastructure() | ||
{ | ||
// Arrange | ||
var presentationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(presentationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(ApiService)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(Infrastructure)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
|
||
[Fact] | ||
public void Presentation_Should_HaveNotDependencyOnPersistence() | ||
{ | ||
// Arrange | ||
var presentationAssembly = AssemblyReference.Assembly; | ||
|
||
// Act | ||
var result = Types.InAssembly(presentationAssembly) | ||
.That() | ||
.ResideInNamespace(nameof(ApiService)) | ||
.ShouldNot() | ||
.HaveDependencyOn(nameof(Persistence)) | ||
.GetResult(); | ||
|
||
// Assert | ||
Assert.True(result.IsSuccessful); | ||
} | ||
} |
Oops, something went wrong.