Add initial project structure and implement basic functionality
- Created MSTestSettings.cs to enable parallel test execution. - Added StyleTests.cs and TitreTests.cs for unit testing of Style and Titre entities. - Implemented Webzine.Entity.Tests project with necessary configurations. - Created SeedDataLocal.cs and SeedDataSpotify.cs for local and Spotify data seeding. - Established repository contracts for Artiste, Commentaire, Style, and Titre. - Developed DbEntityRepository and LocalEntityRepository classes. - Set up Webzine.WebApplication with controllers, logging, and Docker support. - Configured NLog for logging and added necessary appsettings for development. - Created initial views and layout for the web application. - Added Dockerfile and docker-compose configuration for containerization.
This commit is contained in:
25
.dockerignore
Normal file
25
.dockerignore
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/.idea
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
/packages/
|
||||||
|
riderModule.iml
|
||||||
|
/_ReSharper.Caches/
|
||||||
|
[Ll]ogs/
|
||||||
|
.idea/
|
||||||
24
Webzine.Business.Contracts/Webzine.Business.Contracts.csproj
Normal file
24
Webzine.Business.Contracts/Webzine.Business.Contracts.csproj
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
<PackageReference Include="NLog" Version="6.1.1" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
24
Webzine.Business/Webzine.Business.csproj
Normal file
24
Webzine.Business/Webzine.Business.csproj
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
<PackageReference Include="NLog" Version="6.1.1" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
0
Webzine.Documentation/Rapport/equip 1 - rapport.md
Normal file
0
Webzine.Documentation/Rapport/equip 1 - rapport.md
Normal file
9
Webzine.Documentation/StyleCop/stylecop.json
Normal file
9
Webzine.Documentation/StyleCop/stylecop.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||||
|
"settings": {
|
||||||
|
"documentationRules": {
|
||||||
|
"companyName": " Equipe 1 - ",
|
||||||
|
"documentationCulture": "fr-FR"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Webzine.Documentation/Webzine.Documentation.csproj
Normal file
13
Webzine.Documentation/Webzine.Documentation.csproj
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
24
Webzine.EntitiesContext/Webzine.EntitiesContext.csproj
Normal file
24
Webzine.EntitiesContext/Webzine.EntitiesContext.csproj
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
<PackageReference Include="NLog" Version="6.1.1" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
55
Webzine.Entity.Tests/ArtisteTests.cs
Normal file
55
Webzine.Entity.Tests/ArtisteTests.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
namespace Webzine.Entity.Tests
|
||||||
|
{
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests de l'entité <see cref="Artiste"/>.
|
||||||
|
/// Vérifie que les contraintes imposées (nom du champ, longueur max du champ,
|
||||||
|
/// champ obligatoire, libellé du champ, clé primaire...) sont bien respectées.
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public class ArtisteTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void ArtisteHasIdArtiste()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Artiste), nameof(Artiste.IdArtiste));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ArtisteHasNom()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Artiste), nameof(Artiste.Nom));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ArtisteHasNomTailleMin1()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMin(typeof(Artiste), nameof(Artiste.Nom), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ArtisteHasNomTailleMax50()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Artiste), nameof(Artiste.Nom), 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ArtisteHasNomDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Artiste), nameof(Artiste.Nom), "Nom de l'artiste");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ArtisteHasBiographie()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Artiste), nameof(Artiste.Biographie));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ArtisteHasTitres()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Artiste), nameof(Artiste.Titres));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
109
Webzine.Entity.Tests/CommentaireTests.cs
Normal file
109
Webzine.Entity.Tests/CommentaireTests.cs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
namespace Webzine.Entity.Tests
|
||||||
|
{
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests de l'entité <see cref="Commentaire"/>.
|
||||||
|
/// Vérifie que les contraintes imposées (nom du champ, longueur max du champ,
|
||||||
|
/// champ obligatoire, libellé du champ, clé primaire...) sont bien respectées.
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public class CommentaireTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasIdCommentaire()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Commentaire), nameof(Commentaire.IdCommentaire));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasContenu()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Commentaire), nameof(Commentaire.Contenu));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasContenuDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Commentaire), nameof(Commentaire.Contenu), "Commentaire");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasContenuRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Commentaire), nameof(Commentaire.Contenu));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasContenuTailleMin10()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMin(typeof(Commentaire), nameof(Commentaire.Contenu), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasContenuTailleMax1000()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Commentaire), nameof(Commentaire.Contenu), 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasAuteur()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Commentaire), nameof(Commentaire.Auteur));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasAuteurDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Commentaire), nameof(Commentaire.Auteur), "Nom");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasAuteurRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Commentaire), nameof(Commentaire.Auteur));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasAuteurTailleMin2()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMin(typeof(Commentaire), nameof(Commentaire.Auteur), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasAuteurTailleMax30()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Commentaire), nameof(Commentaire.Auteur), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasDateCreation()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Commentaire), nameof(Commentaire.DateCreation));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasDateCreationRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Commentaire), nameof(Commentaire.DateCreation));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasDateCreationDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Commentaire), nameof(Commentaire.DateCreation), "Date de création");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasIdTitre()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Commentaire), nameof(Commentaire.IdTitre));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void CommentaireHasTitre()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Commentaire), nameof(Commentaire.Titre));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
90
Webzine.Entity.Tests/Common.cs
Normal file
90
Webzine.Entity.Tests/Common.cs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
namespace Webzine.Entity.Tests
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Méthodes utilitaires permettant de tester les entités.
|
||||||
|
/// </summary>
|
||||||
|
public static class Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Vérifie que l'entité possède bien la propriété passée en paramètre.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="typeObjet">type de l'entité</param>
|
||||||
|
/// <param name="nomPropriete">nom de la propriété de l'entité</param>
|
||||||
|
public static void HasProperty(Type typeObjet, string nomPropriete)
|
||||||
|
{
|
||||||
|
var property = typeObjet.GetProperty(nomPropriete);
|
||||||
|
Assert.IsNotNull(property, "La classe " + typeObjet.Name + " doit avoir une propriété '" + nomPropriete + "'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vérifie que l'attribut de l'entité a l'annotation [Display(Name = "xxx")] avec la valeur attendue.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="typeObjet">type de l'entité</param>
|
||||||
|
/// <param name="nomPropriete">nom de la propriété de l'entité</param>
|
||||||
|
/// <param name="chaineAttendue">valeur attendue pour l'affichage de cette propriété</param>
|
||||||
|
public static void AttributDisplay(Type typeObjet, string nomPropriete, string chaineAttendue)
|
||||||
|
{
|
||||||
|
var property = typeObjet.GetProperty(nomPropriete);
|
||||||
|
var annotation = (DisplayAttribute)property.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault();
|
||||||
|
Assert.IsNotNull(annotation, "La propriété '" + nomPropriete + "' n'a pas de libellé approprié. Il manque l'annotation Display.");
|
||||||
|
Assert.AreEqual(chaineAttendue, annotation.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vérifie que l'attribut de l'entité a l'annotation [MinLength(xx)] avec la longueur attendue.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="typeObjet">type de l'entité</param>
|
||||||
|
/// <param name="nomPropriete">nom de la propriété de l'entité</param>
|
||||||
|
/// <param name="max">longueur maximum</param>
|
||||||
|
public static void AttributLongueurMax(Type typeObjet, string nomPropriete, int max)
|
||||||
|
{
|
||||||
|
var property = typeObjet.GetProperty(nomPropriete);
|
||||||
|
var annotation = (MaxLengthAttribute)property.GetCustomAttributes(typeof(MaxLengthAttribute), false).FirstOrDefault();
|
||||||
|
Assert.IsNotNull(annotation, "La propriété '" + nomPropriete + "' n'a pas de longueur maximum. Il manque l'annotation MaxLength.");
|
||||||
|
Assert.AreEqual(max, annotation.Length, "La propriété '" + nomPropriete + "' ne doit pas pouvoir dépasser " + max + " caractères.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vérifie que l'attribut de l'entité a l'annotation [MinLength(xx)] avec la longueur attendue.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="typeObjet">type de l'entité</param>
|
||||||
|
/// <param name="nomPropriete">nom de la propriété de l'entité</param>
|
||||||
|
/// <param name="min">longueur minimum</param>
|
||||||
|
public static void AttributLongueurMin(Type typeObjet, string nomPropriete, int min)
|
||||||
|
{
|
||||||
|
var property = typeObjet.GetProperty(nomPropriete);
|
||||||
|
var annotation = (MinLengthAttribute)property.GetCustomAttributes(typeof(MinLengthAttribute), false).FirstOrDefault();
|
||||||
|
Assert.IsNotNull(annotation, "La propriété '" + nomPropriete + "' n'a pas de longueur minimum. Il manque l'annotation MinLength.");
|
||||||
|
Assert.AreEqual(min, annotation.Length, "La propriété '" + nomPropriete + "' ne avoir au moins " + min + " caractères.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vérifie que l'attribut de l'entité a l'annotation [Required].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="typeObjet">type de l'entité</param>
|
||||||
|
/// <param name="nomPropriete">nom de la propriété de l'entité</param>
|
||||||
|
public static void AttributRequis(Type typeObjet, string nomPropriete)
|
||||||
|
{
|
||||||
|
var property = typeObjet.GetProperty(nomPropriete);
|
||||||
|
var annotation = (RequiredAttribute)property.GetCustomAttributes(typeof(RequiredAttribute), false).FirstOrDefault();
|
||||||
|
Assert.IsNotNull(annotation, "La propriété '" + nomPropriete + "' n'est pas obligatoire. Il manque l'annotation Required.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vérifie que l'attribut de l'entité n'a pas l'annotation [Url].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="typeObjet">type de l'entité</param>
|
||||||
|
/// <param name="nomPropriete">nom de la propriété de l'entité</param>
|
||||||
|
public static void AttributHasNotUrlValidation(Type typeObjet, string nomPropriete)
|
||||||
|
{
|
||||||
|
var property = typeObjet.GetProperty(nomPropriete);
|
||||||
|
var annotation = (UrlAttribute)property.GetCustomAttributes(typeof(UrlAttribute), false).FirstOrDefault();
|
||||||
|
Assert.IsNull(annotation, "La propriété '" + nomPropriete + "' ne doit pas être une URL obligatoirement. Retirez l'annotation Url.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Webzine.Entity.Tests/MSTestSettings.cs
Normal file
1
Webzine.Entity.Tests/MSTestSettings.cs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
|
||||||
49
Webzine.Entity.Tests/StyleTests.cs
Normal file
49
Webzine.Entity.Tests/StyleTests.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
namespace Webzine.Entity.Tests
|
||||||
|
{
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests de l'entité <see cref="Style"/>.
|
||||||
|
/// Vérifie que les contraintes imposées (nom du champ, longueur max du champ,
|
||||||
|
/// champ obligatoire, libellé du champ, clé primaire...) sont bien respectées.
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public class StyleTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void StyleHasIdStyle()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Style), nameof(Style.IdStyle));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void StyleHasLibelle()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Style), nameof(Style.Libelle));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void StyleHasLibelleDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Style), nameof(Style.Libelle), "Libellé");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void StyleHasLibelleRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Style), nameof(Style.Libelle));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void StyleHasLibelleTailleMin2()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMin(typeof(Style), nameof(Style.Libelle), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void StyleHasLibelleTailleMax50()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Style), nameof(Style.Libelle), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
241
Webzine.Entity.Tests/TitreTests.cs
Normal file
241
Webzine.Entity.Tests/TitreTests.cs
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
namespace Webzine.Entity.Tests
|
||||||
|
{
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests de l'entité <see cref="Titre"/>.
|
||||||
|
/// Vérifie que les contraintes imposées (nom du champ, longueur max du champ,
|
||||||
|
/// champ obligatoire, libellé du champ, clé primaire...) sont bien respectées.
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public class TitreTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasIdTitre()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.IdTitre));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasIdArtiste()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.IdArtiste));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasArtiste()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.Artiste));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasLibelle()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.Libelle));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasLibelleDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.Libelle), "Titre");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasLibelleRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.Libelle));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasLibelleTailleMin1()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMin(typeof(Titre), nameof(Titre.Libelle), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasLibelleTailleMax200()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Titre), nameof(Titre.Libelle), 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasChronique()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.Chronique));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasChroniqueRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.Chronique));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasChroniqueTailleMin10()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMin(typeof(Titre), nameof(Titre.Chronique), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasChroniqueTailleMax4000()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Titre), nameof(Titre.Chronique), 4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDateCreation()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.DateCreation));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDateCreationRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.DateCreation));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDateCreationDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.DateCreation), "Date de création");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDuree()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.Duree));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDureeDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.Duree), "Durée en secondes");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDateSortie()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.DateSortie));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDateSortieRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.DateSortie));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasDateSortieDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.DateSortie), "Date de sortie");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlJaquette()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.UrlJaquette));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlJaquetteRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.UrlJaquette));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlJaquetteDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.UrlJaquette), "Jaquette de l'album");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlJaquetteTailleMax250()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Titre), nameof(Titre.UrlJaquette), 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlEcoute()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.UrlEcoute));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlEcouteDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.UrlEcoute), "URL d'écoute");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlEcouteTailleMin13()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMin(typeof(Titre), nameof(Titre.UrlEcoute), 13);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasUrlEcouteTailleMax250()
|
||||||
|
{
|
||||||
|
Common.AttributLongueurMax(typeof(Titre), nameof(Titre.UrlEcoute), 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasNbLectures()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.NbLectures));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasNbLecturesDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.NbLectures), "Nombre de lectures");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasNbLecturesRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.NbLectures));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasNbLikes()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.NbLikes));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasNbLikesDisplayValid()
|
||||||
|
{
|
||||||
|
Common.AttributDisplay(typeof(Titre), nameof(Titre.NbLikes), "Nombre de likes");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasNbLikesRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.NbLikes));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasAlbum()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.Album));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasAlbumRequis()
|
||||||
|
{
|
||||||
|
Common.AttributRequis(typeof(Titre), nameof(Titre.Album));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreHasCommentaires()
|
||||||
|
{
|
||||||
|
Common.HasProperty(typeof(Titre), nameof(Titre.Commentaires));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TitreUrlJaquetteeIsNotMandatory()
|
||||||
|
{
|
||||||
|
Common.AttributHasNotUrlValidation(typeof(Titre), nameof(Titre.UrlJaquette));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Webzine.Entity.Tests/Webzine.Entity.Tests.csproj
Normal file
28
Webzine.Entity.Tests/Webzine.Entity.Tests.csproj
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MSTest" Version="4.0.1"/>
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
5
Webzine.Entity/Fixtures/SeedDataLocal.cs
Normal file
5
Webzine.Entity/Fixtures/SeedDataLocal.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Webzine.EntitiesContext;
|
||||||
|
|
||||||
|
public class SeedDataLocal
|
||||||
|
{
|
||||||
|
}
|
||||||
6
Webzine.Entity/Fixtures/SeedDataSpotify.cs
Normal file
6
Webzine.Entity/Fixtures/SeedDataSpotify.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Webzine.EntitiesContext;
|
||||||
|
|
||||||
|
public class SeedDataSpotify
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
24
Webzine.Entity/Webzine.Entity.csproj
Normal file
24
Webzine.Entity/Webzine.Entity.csproj
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
<PackageReference Include="NLog" Version="6.1.1" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
17
Webzine.Repository.Contracts/IArtisteRepository.cs
Normal file
17
Webzine.Repository.Contracts/IArtisteRepository.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// using Webzine.Entity;
|
||||||
|
|
||||||
|
namespace Webzine.Repository.Contracts
|
||||||
|
{
|
||||||
|
public interface IArtisteRepository
|
||||||
|
{
|
||||||
|
// void Add(Artiste artiste);
|
||||||
|
|
||||||
|
// void Delete(Artiste artiste);
|
||||||
|
|
||||||
|
// Artiste Find(int id);
|
||||||
|
|
||||||
|
// IEnumerable<Artiste> FindAll();
|
||||||
|
|
||||||
|
// void Update(Artiste artiste);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Webzine.Repository.Contracts/ICommentaireRepository.cs
Normal file
15
Webzine.Repository.Contracts/ICommentaireRepository.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// using Webzine.Entity;
|
||||||
|
|
||||||
|
namespace Webzine.Repository.Contracts
|
||||||
|
{
|
||||||
|
public interface ICommentaireRepository
|
||||||
|
{
|
||||||
|
// void Add(Commentaire commentaire);
|
||||||
|
|
||||||
|
// void Delete(Commentaire commentaire);
|
||||||
|
|
||||||
|
// Commentaire Find(int id);
|
||||||
|
|
||||||
|
// IEnumerable<Commentaire> FindAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Webzine.Repository.Contracts/IStyleRepository.cs
Normal file
17
Webzine.Repository.Contracts/IStyleRepository.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// using Webzine.Entity;
|
||||||
|
|
||||||
|
namespace Webzine.Repository.Contracts
|
||||||
|
{
|
||||||
|
public interface IStyleRepository
|
||||||
|
{
|
||||||
|
// void Add(Style style);
|
||||||
|
|
||||||
|
// void Delete(Style style);
|
||||||
|
|
||||||
|
// Style Find(int id);
|
||||||
|
|
||||||
|
// IEnumerable<Style> FindAll();
|
||||||
|
|
||||||
|
// void Update(Style style);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Webzine.Repository.Contracts/ITtitreRepository.cs
Normal file
29
Webzine.Repository.Contracts/ITtitreRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// using Webzine.Entity;
|
||||||
|
|
||||||
|
namespace Webzine.Repository.Contracts
|
||||||
|
{
|
||||||
|
public interface ITitreRepository
|
||||||
|
{
|
||||||
|
// void Add(Titre titre);
|
||||||
|
|
||||||
|
// int Count();
|
||||||
|
|
||||||
|
// void Delete(Titre titre);
|
||||||
|
|
||||||
|
// Titre Find(int idTitre);
|
||||||
|
|
||||||
|
// IEnumerable<Titre> FindTitres(int offset, int limit);
|
||||||
|
|
||||||
|
// IEnumerable<Titre> FindAll();
|
||||||
|
|
||||||
|
// void IncrementNbLectures(Titre titre);
|
||||||
|
|
||||||
|
// void IncrementNbLikes(Titre titre);
|
||||||
|
|
||||||
|
// IEnumerable<Titre> Search(string mot);
|
||||||
|
|
||||||
|
// IEnumerable<Titre> SearchByStyle(string libelle);
|
||||||
|
|
||||||
|
// void Update(Titre titre);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
<PackageReference Include="NLog" Version="6.1.1" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
6
Webzine.Repository/DbEntityRepository.cs
Normal file
6
Webzine.Repository/DbEntityRepository.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Webzine.Repository;
|
||||||
|
|
||||||
|
public class DbEntityRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
5
Webzine.Repository/LocalEntityRepository.cs
Normal file
5
Webzine.Repository/LocalEntityRepository.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Webzine.Repository;
|
||||||
|
|
||||||
|
public class LocalEntityRepository
|
||||||
|
{
|
||||||
|
}
|
||||||
24
Webzine.Repository/Webzine.Repository.csproj
Normal file
24
Webzine.Repository/Webzine.Repository.csproj
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
<PackageReference Include="NLog" Version="6.1.1" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
27
Webzine.WebApplication/Controllers/api/VersionController.cs
Normal file
27
Webzine.WebApplication/Controllers/api/VersionController.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Webzine.WebApplication.Controllers.api;
|
||||||
|
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class VersionController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<VersionController> _logger;
|
||||||
|
|
||||||
|
public VersionController(ILogger<VersionController> logger)
|
||||||
|
{
|
||||||
|
this._logger = logger;
|
||||||
|
this._logger.LogDebug(1, "NLog injected into VersionController");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get()
|
||||||
|
{
|
||||||
|
this._logger.LogInformation("Get Version was called");
|
||||||
|
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
nom = "webzine",
|
||||||
|
version = "1.0",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
23
Webzine.WebApplication/Dockerfile
Normal file
23
Webzine.WebApplication/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
||||||
|
USER $APP_UID
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 8080
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["Webzine.WebApplication/Webzine.WebApplication.csproj", "Webzine.WebApplication/"]
|
||||||
|
RUN dotnet restore "Webzine.WebApplication/Webzine.WebApplication.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/Webzine.WebApplication"
|
||||||
|
RUN dotnet build "./Webzine.WebApplication.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "./Webzine.WebApplication.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "Webzine.WebApplication.dll"]
|
||||||
52
Webzine.WebApplication/Program.cs
Normal file
52
Webzine.WebApplication/Program.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using NLog;
|
||||||
|
using NLog.Web;
|
||||||
|
|
||||||
|
// Early init of NLog to allow startup and exception logging, before host is built
|
||||||
|
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||||
|
logger.Debug("init main");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Ajoute les services n<>cessaires pour permettre l'utilisation des
|
||||||
|
// controllers avec des vues.
|
||||||
|
builder.Services.AddControllersWithViews()
|
||||||
|
// Ajoute la compilation des vues lors de l'ex<65>cution de l'application.
|
||||||
|
// Cela nous <20>vite de recompiler l'application <20> chaque modification de vue.
|
||||||
|
// N<>cessite le package Nuget Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.
|
||||||
|
.AddRazorRuntimeCompilation();
|
||||||
|
|
||||||
|
// NLog: Setup NLog for Dependency injection
|
||||||
|
builder.Logging.ClearProviders();
|
||||||
|
builder.Host.UseNLog();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Active la possibilit<69> de servir des fichiers statiques pr<70>sents dans
|
||||||
|
// le dossier wwwroot.
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
// Active le middleware permettant le routage des requ<71>tes entrantes.
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
// Ajoute un endpoint permettant de router les urls
|
||||||
|
// avec la forme /controller/action/id(optionnel).
|
||||||
|
// Equivalent <20> app.MapDefaultControllerRoute()
|
||||||
|
app.MapControllerRoute(
|
||||||
|
name: "default",
|
||||||
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
// NLog: catch setup errors
|
||||||
|
logger.Error(exception, "Stopped program because of exception");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
||||||
|
NLog.LogManager.Shutdown();
|
||||||
|
}
|
||||||
23
Webzine.WebApplication/Properties/launchSettings.json
Normal file
23
Webzine.WebApplication/Properties/launchSettings.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "http://localhost:5038",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7095;http://localhost:5038",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Webzine.WebApplication/Views/Shared/_Layout.cshtml
Normal file
15
Webzine.WebApplication/Views/Shared/_Layout.cshtml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@ViewData["Title"] - Mon Application</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
@RenderBody()
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
||||||
|
</html>
|
||||||
2
Webzine.WebApplication/Views/_ViewImports.cshtml
Normal file
2
Webzine.WebApplication/Views/_ViewImports.cshtml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@* Permet de factoriser les imports de tag helpers *@
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
3
Webzine.WebApplication/Views/_ViewStart.cshtml
Normal file
3
Webzine.WebApplication/Views/_ViewStart.cshtml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "_Layout";
|
||||||
|
}
|
||||||
36
Webzine.WebApplication/Webzine.WebApplication.csproj
Normal file
36
Webzine.WebApplication/Webzine.WebApplication.csproj
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\.dockerignore">
|
||||||
|
<Link>.dockerignore</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||||
|
<Link>stylecop.json</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="wwwroot\data\" />
|
||||||
|
<Folder Include="wwwroot\js\" />
|
||||||
|
<Folder Include="wwwroot\lib\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="10.0.3" />
|
||||||
|
<PackageReference Include="NLog.Web.AspNetCore" Version="5.*" />
|
||||||
|
<PackageReference Include="NLog" Version="5.*" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
8
Webzine.WebApplication/appsettings.Development.json
Normal file
8
Webzine.WebApplication/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Webzine.WebApplication/appsettings.json
Normal file
9
Webzine.WebApplication/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
40
Webzine.WebApplication/nlog.config
Normal file
40
Webzine.WebApplication/nlog.config
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
autoReload="true"
|
||||||
|
throwConfigExceptions="true"
|
||||||
|
internalLogLevel="Info"
|
||||||
|
internalLogFile="/Logs/internal-nlog-AspNetCore.txt">
|
||||||
|
|
||||||
|
<extensions>
|
||||||
|
<add assembly="NLog.Web.AspNetCore"/>
|
||||||
|
</extensions>
|
||||||
|
|
||||||
|
<targets>
|
||||||
|
<!-- Journalisation complète -->
|
||||||
|
<target xsi:type="File" name="allfile"
|
||||||
|
fileName="/Logs/nlog-all-${shortdate}.log"
|
||||||
|
layout="${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}" />
|
||||||
|
|
||||||
|
<!-- Journalisation spécifique avec détails web -->
|
||||||
|
<target xsi:type="File" name="ownfile-web"
|
||||||
|
fileName="/Logs/nlog-own-${shortdate}.log"
|
||||||
|
layout="${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}|${aspnet-request-url:whenEmpty=NoRequest}" />
|
||||||
|
|
||||||
|
<!-- Console pour debug immédiat -->
|
||||||
|
<target xsi:type="Console" name="console"
|
||||||
|
layout="${longdate}|${level:uppercase=true}|${logger}|${message}" />
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<!-- Vos logs d'application en Debug+ -->
|
||||||
|
<logger name="Webzine.WebApplication.*" minlevel="Debug" writeTo="allfile,ownfile-web,console" />
|
||||||
|
|
||||||
|
<!-- Logs Microsoft en Warning+ sauf Hosting.Lifetime -->
|
||||||
|
<logger name="Microsoft.*" minlevel="Warn" writeTo="allfile" final="true" />
|
||||||
|
<logger name="Microsoft.Hosting.Lifetime*" minlevel="Info" writeTo="allfile,console" final="true" />
|
||||||
|
|
||||||
|
<!-- Tous les autres logs (y compris System) en Info+ -->
|
||||||
|
<logger name="*" minlevel="Info" writeTo="allfile" />
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
0
Webzine.WebApplication/wwwroot/css/app.css
Normal file
0
Webzine.WebApplication/wwwroot/css/app.css
Normal file
0
Webzine.WebApplication/wwwroot/favicon.ico
Normal file
0
Webzine.WebApplication/wwwroot/favicon.ico
Normal file
0
Webzine.WebApplication/wwwroot/images/avater.png
Normal file
0
Webzine.WebApplication/wwwroot/images/avater.png
Normal file
0
Webzine.WebApplication/wwwroot/js/app.js
Normal file
0
Webzine.WebApplication/wwwroot/js/app.js
Normal file
69
Webzine.sln
Normal file
69
Webzine.sln
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.WebApplication", "Webzine.WebApplication\Webzine.WebApplication.csproj", "{0F21D365-A429-4078-BB2E-25AD48483016}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F4D1022B-2133-4DF2-B9E0-C1A75348E57D}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
compose.yaml = compose.yaml
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.Business", "Webzine.Business\Webzine.Business.csproj", "{4D3B7572-1665-4F16-9918-96BEA738EDD7}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.Business.Contracts", "Webzine.Business.Contracts\Webzine.Business.Contracts.csproj", "{723DDF70-4F85-4C47-B749-5B64FEC632E2}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.Entity", "Webzine.Entity\Webzine.Entity.csproj", "{363C9517-4EA7-4878-9F7A-D3923722B51C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.EntitiesContext", "Webzine.EntitiesContext\Webzine.EntitiesContext.csproj", "{9362A3F0-FC38-4D84-AEE6-8313D2417229}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.Repository", "Webzine.Repository\Webzine.Repository.csproj", "{05A69CDF-B96A-4F2F-A0F5-68C5C77DAAB5}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.Repository.Contracts", "Webzine.Repository.Contracts\Webzine.Repository.Contracts.csproj", "{F3FF8EC4-DAC7-4BD4-BBAB-1CF0F32A6EBC}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.Documentation", "Webzine.Documentation\Webzine.Documentation.csproj", "{0FD5670B-BF47-4596-B26D-0AD3A07EC67C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webzine.Entity.Tests", "Webzine.Entity.Tests\Webzine.Entity.Tests.csproj", "{1B8008AD-7554-43CE-A041-186AFB1CEA01}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0F21D365-A429-4078-BB2E-25AD48483016}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0F21D365-A429-4078-BB2E-25AD48483016}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0F21D365-A429-4078-BB2E-25AD48483016}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0F21D365-A429-4078-BB2E-25AD48483016}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4D3B7572-1665-4F16-9918-96BEA738EDD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4D3B7572-1665-4F16-9918-96BEA738EDD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4D3B7572-1665-4F16-9918-96BEA738EDD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4D3B7572-1665-4F16-9918-96BEA738EDD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{723DDF70-4F85-4C47-B749-5B64FEC632E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{723DDF70-4F85-4C47-B749-5B64FEC632E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{723DDF70-4F85-4C47-B749-5B64FEC632E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{723DDF70-4F85-4C47-B749-5B64FEC632E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{363C9517-4EA7-4878-9F7A-D3923722B51C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{363C9517-4EA7-4878-9F7A-D3923722B51C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{363C9517-4EA7-4878-9F7A-D3923722B51C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{363C9517-4EA7-4878-9F7A-D3923722B51C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9362A3F0-FC38-4D84-AEE6-8313D2417229}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9362A3F0-FC38-4D84-AEE6-8313D2417229}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9362A3F0-FC38-4D84-AEE6-8313D2417229}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9362A3F0-FC38-4D84-AEE6-8313D2417229}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{05A69CDF-B96A-4F2F-A0F5-68C5C77DAAB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{05A69CDF-B96A-4F2F-A0F5-68C5C77DAAB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{05A69CDF-B96A-4F2F-A0F5-68C5C77DAAB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{05A69CDF-B96A-4F2F-A0F5-68C5C77DAAB5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F3FF8EC4-DAC7-4BD4-BBAB-1CF0F32A6EBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F3FF8EC4-DAC7-4BD4-BBAB-1CF0F32A6EBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F3FF8EC4-DAC7-4BD4-BBAB-1CF0F32A6EBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F3FF8EC4-DAC7-4BD4-BBAB-1CF0F32A6EBC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0FD5670B-BF47-4596-B26D-0AD3A07EC67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0FD5670B-BF47-4596-B26D-0AD3A07EC67C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0FD5670B-BF47-4596-B26D-0AD3A07EC67C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0FD5670B-BF47-4596-B26D-0AD3A07EC67C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1B8008AD-7554-43CE-A041-186AFB1CEA01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1B8008AD-7554-43CE-A041-186AFB1CEA01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1B8008AD-7554-43CE-A041-186AFB1CEA01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1B8008AD-7554-43CE-A041-186AFB1CEA01}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
7
compose.yaml
Normal file
7
compose.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
webzine.webapplication:
|
||||||
|
image: webzine.webapplication
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Webzine.WebApplication/Dockerfile
|
||||||
|
|
||||||
Reference in New Issue
Block a user