One of the problem with NuGet are version .One of the problems with version is that ,in the same sln, inadvertently add 2 NuGets with different versions.
Added deployment
After this ADR
Added deployment
After this ADR
Added versioning
It is difficult to find documentation about what packages to add for versioning WebAPI .
Adding WebAPI
Adding WebAPI is not big deal. But what do you need , for a Good functionality ?
Adding logging
Adding logging for a project should be simple, right ?
Refactoring
Now the project syncPowershellObjects is full of interfaces and classes. I need a refactoring - to, at least,separate interfaces from classes/implemented functionalities.
It is easy to create a new project and to add the interfaces ( with a new namespace). Somehow more difficult is to respect the rule : the interfaces must not have other the methods / properties that are not interfaces . This infers generating interfaces from classes ( VS is perfect!).
So now is how it looks( generated with https://www.nuget.org/packages/netpackageanalyzerconsole )
And some major versions that differs already , even if all is targeting 7.0!
Number of packages that differ in major version : 3
1 System.Collections.Immutable
2 System.Reflection.Metadata
3 System.Text.Encoding.CodePages
And here are the results of the tests:
Feature: TestUploadAndRetrieve
In order to sync powershell profile
As an anonymous
I want to send my powershell profile
and retrieve data
Scenario: TestOnePC No Powershell [UseCase002] - Passed (1s 071ms)
Categories: TestOnePC
Step 1: GIVEN NoPowershellProfile7 IsFound For UserName "Andrei" "TestPCAndrei" - Passed (18ms)
Step 2: WHEN the data is sent - Passed (1s 018ms)
Step 3: THEN the return value should be an URL Ending In UserName "Andrei" "TestPCAndrei" - Passed (2ms)
Scenario: TestOnePC Powershell7 Exists [UseCase001] - Passed (1s 061ms)
Categories: TestOnePC
Step 1: GIVEN PowershellProfile7 IsFound For UserName "Andrei" "TestPCAndrei" [value: "text"] - Passed (2ms)
Step 2: WHEN the data is sent - Passed (1s 048ms)
Step 3: THEN the return value should be an URL Ending In UserName "Andrei" "TestPCAndrei" With ID - Passed (1ms)
Scenario: TestOnePC Powershell7 Exists RetrieveData [UseCase003] - Passed (1s 031ms)
Categories: TestOnePC
Step 1: GIVEN PowershellProfile7 IsFound For UserName "Andrei" "TestPCAndrei" [value: "text"] - Passed (<1ms)
Step 2: WHEN the data is sent - Passed (1s 012ms)
Step 3: THEN the return value should be an URL Ending In UserName "Andrei" "TestPCAndrei" With ID - Passed (<1ms)
Step 4: AND Can Retrieve Data [userName: "Andrei"] [pc: "TestPCAndrei"] [pwshNumber: "7"] [retValue: "text"] - Passed (5ms)
Testing saving and retrieval
Now for the tests that are sending and retrieving data, it is not enough to verify with mocks/stubs ( see https://martinfowler.com/articles/mocksArentStubs.html ) .
There must be some real objects that saves / retrieves data, otherwise it is just mocking the answer.
So now how to store data
Analysis of the project
Before starting writing API, I want to generate data about what I have created - packages, reference , tests .
For tests, I have copied the PlainTextReportFormatter from https://github.com/LightBDD/LightBDD/blob/c07341ea8dc90d5c2dae74650d9bdad848978100/src/LightBDD.Framework/Reporting/Formatters/PlainTextReportFormatter.cs#L19
and
- modified a bit ( put # in front of Summary , Scenario , Feature, )
- Commented new TextTableRenderer , TextTreeRenderer.Render for later use
And voila!
For analyzing the project I use https://github.com/ignatandrei/PackageAnalyzer .
This will export the package references, the relations between packages, the packages with differences in the major ...
The result is here:
https://ignatandrei.github.io/syncPowershellProfile/docs/category/technical-docs
Code Coverage
This is another decision - how much code coverage should be and how to obtain it.
For Code Coverage, I have worked until now with
https://github.com/danielpalme/ReportGenerator
that works with XPlat Code Coverage
https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-code-coverage?tabs=windows
But now I have seen a tool that does it all:
https://www.jetbrains.com/help/dotcover/Running_Coverage_Analysis_from_the_Command_LIne.html
The xml for configuring is dotnetcover.xml
<CoverageParams>
<ReportType>HTML</ReportType>
<Filters>
<ExcludeFilters>
<FilterEntry>
<ModuleMask>*Tests*</ModuleMask>
</FilterEntry>
<FilterEntry>
<ClassMask>*clsSystem*</ClassMask>
</FilterEntry>
<FilterEntry>
<ClassMask>*recSystem*</ClassMask>
</FilterEntry>
<FilterEntry>
<ClassMask>*StaticToInterface*</ClassMask>
</FilterEntry>
<FilterEntry>
<ClassMask>*TestPlatform*</ClassMask>
</FilterEntry>
<FilterEntry>
<ClassMask>*Refit.Implementation*</ClassMask>
</FilterEntry>
</ExcludeFilters>
</Filters>
</CoverageParams>
And for code coverage, should be at least 80%.
Also, install this .net tools:
{
"version": 1,
"isRoot": true,
"tools": {
"jetbrains.dotcover.globaltool": {
"version": "2023.2.1",
"commands": [
"dotnet-dotcover"
]
},
"run-script": {
"version": "0.5.0",
"commands": [
"r"
]
},
"powershell": {
"version": "7.3.6",
"commands": [
"pwsh"
]
}
}
}
And to run this is the global.json
{
"scripts": {
"build": "dotnet build --configuration Release",
"test": "dotnet dotnet-dotcover test --dcXml=dotnetcover.xml",
"ci": "dotnet r build && dotnet r test"
}
}
Also, need saving this
Continuing tests - no data
Since the powershell file profile can exists or not , we need a new UseCase
First , rename use cases from 003 to 030 - to let space for others.
So a new
Documentation
I have started documentation about how to use, put the ADR and UseCases in their own folder, modified links, added about.
Starting tests
For starting tests there is a plethora of frameworks. What we want is to
Use Cases as mermaid
Modified use cases to see the interaction as mermaid.
General Architecture
I want to have a simple application , without fuss. It will be an WebAPI Application, a Database and a SPA app.
Modifications : Added also use case 4, the list of users Added also max dimension for files Refactored useCases to their folder
Here it comes the ADR :
Use Cases
I want to describe the application in detail - so what's best than a use case ?
Work on documentation
To have automatically documentation , I have created
Documentation
I want the project start with documentation - too many times I wrote the code without documentation.
So I am ready for the first decision - what documentation engine to use.
Start project
Because I am moving from PC to PC and I use powershell ( ok , windows terminal ) I decide to have the $profile synchronized easy What I need is :
Welcome
Docusaurus blogging features are powered by the blog plugin.
Simply add Markdown files (or folders) to the blog
directory.
Regular blog authors can be added to authors.yml
.
The blog post date can be extracted from filenames, such as:
2019-05-30-welcome.md
2019-05-30-welcome/index.md
A blog post folder can be convenient to co-locate blog post images:
The blog supports tags as well!
And if you don't want a blog: just delete this directory, and use blog: false
in your Docusaurus config.
MDX Blog Post
Blog posts support Docusaurus Markdown features, such as MDX.
Use the power of React to create interactive blog posts.
<button onClick={() => alert('button clicked!')}>Click me!</button>
Long Blog Post
This is the summary of a very long blog post,
Use a <!--
truncate
-->
comment to limit blog post size in the list view.
First Blog Post
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet