Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a page object with a title property (#1)
* Define the project structure as architectural decision record * Add page object with title property * Avoid coverage.json genereated by coverlet to be commited
- Loading branch information
Showing
7 changed files
with
136 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin/ | ||
obj/ | ||
|
||
coverage.json |
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,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.0.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\DotNetCMS.Domain\DotNetCMS.Domain.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,16 @@ | ||
using DotNetCMS.Domain.Pages; | ||
using Xunit; | ||
|
||
namespace DotNetCMS.Domain.Tests.Pages | ||
{ | ||
public class PageTest | ||
{ | ||
[Theory] | ||
[InlineData("Page Title 1"), InlineData("Page Title 2")] | ||
public void ConstructWithTitle(string title) | ||
{ | ||
var page = new Page(title); | ||
Assert.Equal(title, page.Title); | ||
} | ||
} | ||
} |
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,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
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,12 @@ | ||
namespace DotNetCMS.Domain.Pages | ||
{ | ||
public class Page | ||
{ | ||
public string Title { get; private set; } | ||
|
||
public Page(string title) | ||
{ | ||
Title = title; | ||
} | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
documentation/architecture-decision-records/0001-project-structure.md
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,41 @@ | ||
# Project Structure | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
Which projects should exist within the solution? This question can also be split in two sub questions: | ||
|
||
1. Should tests be located in the same project as the production code? | ||
2. Should all the production code be located in a single project or should it be split in some way? | ||
|
||
## Decision | ||
|
||
The project structure within this solution is guided by the following two decisions: | ||
|
||
1. Tests will be located in a separated project, [as done in the official Microsoft | ||
documentation](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-dotnet-test). | ||
2. The rest of the solution will be [split by layers](https://softwareengineering.stackexchange.com/a/373533/172973) | ||
according to the yet to be defined layer or onion architecture. | ||
|
||
## Consequences | ||
|
||
The consequences of the first decision are: | ||
|
||
- Tests will have to add `using` statements and references to the other project, which is a bit of an additional | ||
overhead. | ||
- The [assemblies containing the production code will be smaller](https://stackoverflow.com/a/347177/1292378), because | ||
they do not contain the tests, which are unnecessary in a production environment. | ||
|
||
|
||
The consequences of the second decision are: | ||
|
||
- There will be a `DotNetCMS.Domain` project, which is currently holding all domain logic. | ||
- The `DotNetCMS.Domain` project might be split in more projects in the future, e.g. to allow extending a very basic | ||
implementation to be extended with assemblies resp. packages. But at the moment it is hard to decide and going with a | ||
single project will speed up development. | ||
- Multiple projects [provide a good boundary for code isolation](https://stackoverflow.com/a/2658726/1292378). | ||
- Multiple projects [might cause classes to be clustered, because developers might not understand how they are | ||
split](https://stackoverflow.com/a/2658726/1292378) |