Skip to content

Commit

Permalink
Add a page object with a title property (#1)
Browse files Browse the repository at this point in the history
* 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
danrot committed Jul 28, 2021
1 parent e42956e commit b53bbe3
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
bin/
obj/

coverage.json
26 changes: 26 additions & 0 deletions DotNetCMS.Domain.Tests/DotNetCMS.Domain.Tests.csproj
@@ -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>
16 changes: 16 additions & 0 deletions DotNetCMS.Domain.Tests/Pages/PageTest.cs
@@ -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);
}
}
}
7 changes: 7 additions & 0 deletions DotNetCMS.Domain/DotNetCMS.Domain.csproj
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>
12 changes: 12 additions & 0 deletions DotNetCMS.Domain/Pages/Page.cs
@@ -0,0 +1,12 @@
namespace DotNetCMS.Domain.Pages
{
public class Page
{
public string Title { get; private set; }

public Page(string title)
{
Title = title;
}
}
}
30 changes: 30 additions & 0 deletions DotNetCMS.sln
Expand Up @@ -3,6 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCMS.Domain", "DotNetCMS.Domain\DotNetCMS.Domain.csproj", "{91F6404F-E93E-4141-8DCC-BD6071154236}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCMS.Domain.Tests", "DotNetCMS.Domain.Tests\DotNetCMS.Domain.Tests.csproj", "{0006E64F-6987-44E6-845C-ED3977913AF9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,4 +19,30 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91F6404F-E93E-4141-8DCC-BD6071154236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Debug|x64.ActiveCfg = Debug|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Debug|x64.Build.0 = Debug|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Debug|x86.ActiveCfg = Debug|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Debug|x86.Build.0 = Debug|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Release|Any CPU.Build.0 = Release|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Release|x64.ActiveCfg = Release|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Release|x64.Build.0 = Release|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Release|x86.ActiveCfg = Release|Any CPU
{91F6404F-E93E-4141-8DCC-BD6071154236}.Release|x86.Build.0 = Release|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Debug|x64.ActiveCfg = Debug|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Debug|x64.Build.0 = Debug|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Debug|x86.ActiveCfg = Debug|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Debug|x86.Build.0 = Debug|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Release|Any CPU.Build.0 = Release|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Release|x64.ActiveCfg = Release|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Release|x64.Build.0 = Release|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Release|x86.ActiveCfg = Release|Any CPU
{0006E64F-6987-44E6-845C-ED3977913AF9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
@@ -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)

0 comments on commit b53bbe3

Please sign in to comment.