Skip to content

Commit d9a9646

Browse files
committed
[Refactor] Added FluentAssertions nuget package in test project
1 parent a5948d4 commit d9a9646

File tree

10 files changed

+133
-84
lines changed

10 files changed

+133
-84
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
{
22
"version": 1,
33
"isRoot": true,
4-
"tools": {
5-
"paket": {
6-
"version": "5.247.4",
7-
"commands": [
8-
"paket"
9-
]
10-
}
11-
}
4+
"tools": {}
125
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ PublishScripts/
199199
.ci/**/*-schema.json
200200

201201
# NuGet
202-
nugets/
202+
nupkg/
203203
*.nupkg
204204
# NuGet Symbol Packages
205205
*.snupkg

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "process",
88
"args": [
99
"build",
10-
"${workspaceFolder}/ComponentBase/ComponentBase.csproj",
10+
"${workspaceFolder}/ComponentBase.Core/ComponentBase.Core.csproj",
1111
"/property:GenerateFullPaths=true",
1212
"/consoleloggerparameters:NoSummary"
1313
],

ComponentBase.Tests/MyComponentTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using NUnit.Framework;
2+
using FluentAssertions;
23

34
namespace ComponentBase.Tests
45
{
@@ -15,5 +16,16 @@ public void TestIfMethodReturnAString()
1516
var obj = new MyComponent();
1617
Assert.AreEqual("This is a method", obj.Method());
1718
}
19+
20+
/// <summary>
21+
/// For more extra BDD style assertions for <b>C#</b> unit tests: <br/>
22+
/// See <a href="https://fluentassertions.com/introduction">Fluent Assertions Documentation</a>
23+
/// </summary>
24+
[Test, Description("Example test using Behaviour Driven Development (BDD) style approach, with FluentAssertions nuget package")]
25+
public void TestWithBddAssertions()
26+
{
27+
var obj = new MyComponent();
28+
obj.Method().Should().Equals("This is a method");
29+
}
1830
}
1931
}

ComponentBase.Tests/paket.references

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
group Test
2-
nunit
3-
NUnit3TestAdapter
4-
Microsoft.NET.Test.Sdk
5-
NUnit.ConsoleRunner
2+
nunit
3+
NUnit3TestAdapter
4+
Microsoft.NET.Test.Sdk
5+
NUnit.ConsoleRunner
6+
FluentAssertions

ComponentBase/ComponentBase.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
<PropertyGroup>
44
<Title>Component Base</Title>
55
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
6+
<LangVersion>8.0</LangVersion>
67
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7-
<Version>0.0.2</Version>
8+
<Version>0.0.3</Version>
89
<PackageLicenseExpression>MIT</PackageLicenseExpression>
910
<Description>This is a base scaffold for paket/nuget packages</Description>
1011
<Authors>Felipe Ferreira</Authors>
1112
<Company>O-Pitblast</Company>
1213
<PackageTags>component, component-scaffold, nuget-component, dotnet-package</PackageTags>
14+
<PackageOutputPath>./nupkg</PackageOutputPath>
1315
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1416
<SignAssembly>false</SignAssembly>
1517
<!--Symbols for debug the .dll of this package-->
@@ -22,4 +24,7 @@
2224
<DocumentationFile></DocumentationFile>
2325
</PropertyGroup>
2426
<Import Project="..\.paket\Paket.Restore.targets" />
27+
<Target Name="Clean">
28+
<RemoveDir Directories="./nupkg" />
29+
</Target>
2530
</Project>

ComponentBase/paket.references

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
NETStandard.Library

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ Use [.NET Core tools](https://docs.microsoft.com/en-us/dotnet/core/tools/global-
5555
dotnet tool install -g paket
5656
```
5757

58-
**PS:** Install globally if you will use paket in others projects. You can use globally also if your project not use .NET Core.
58+
If you got any error using `paket` with **.NET Core**, try install using chocolatey
59+
60+
```bash
61+
choco install paket
62+
```
63+
64+
> **PS:** Install globally if you will use paket in others projects. You can use globally also if your project not use .NET Core.
5965

6066
#### 3.1 Install Azure pipelines CLI (OPTIONAL)
6167

@@ -96,8 +102,8 @@ Your project folders structure should be:
96102
- 📂 __ComponentBase.Tests__
97103
> The project with Unit and/or Integration tests
98104
- 📄 [ComponentBase.Tests.csproj](ComponentBase.Tests/ComponentBase.Tests.csproj)
99-
- 📂 __ComponentBase__
100-
> The project with your library/component
105+
- 📂 __ComponentBase.Core__
106+
> The project with your library/component core
101107
- 📄 [ComponentBaseComponent.csproj](ComponentBaseComponent/ComponentBaseComponent.csproj)
102108

103109
![component-directories-explanation](./images/component-tree-explanation.png)
@@ -116,8 +122,8 @@ Your project folders structure should be:
116122
2. Genarate the ```.nupkg``` file
117123

118124
```bash
119-
# Pack your component to the path nugets/*.nupkg
120-
dotnet pack --include-symbols --configuration Release --output nugets [your-component-project]
125+
# Pack your component to the path nupkg/*.nupkg
126+
dotnet pack --include-symbols --configuration Release --output .\nupkg [your-component-project]
121127
```
122128
> **PS:** If you not pass the **_--outputs_** flag, the ```.nupkg``` file is generated in: ```[your-component-project]/bin/Release``` by default
123129

@@ -130,7 +136,7 @@ Your project folders structure should be:
130136
If you got a `Pack task` error with .NET Core CLI or in **Visual Studio**, use [`Paket pack`](https://fsprojects.github.io/Paket/paket-pack.html) command:
131137

132138
```bash
133-
paket pack --template [your-component-project]\[your-component-project].csproj.paket.template --build-config Release --symbols nugets
139+
paket pack --template [your-component-project]\[your-component-project].csproj.paket.template --build-config Release --symbols .\nupkg
134140
```
135141

136142
## Testing your package locally

paket.dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
source https://api.nuget.org/v3/index.json
22

33
framework: auto-detect
4-
nuget NETStandard.Library
54

65
group Test
76

87
source https://api.nuget.org/v3/index.json
98

9+
nuget FluentAssertions
1010
nuget Microsoft.NET.Test.Sdk
1111
nuget nunit
1212
nuget NUnit3TestAdapter

paket.lock

Lines changed: 94 additions & 61 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)