Merge pull request 'Merge_API_EF' (#6) from Merge_API_EF into master
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
Reviewed-on: #6Merge_API_EF^2
commit
dde5e1f09a
@ -0,0 +1,82 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: CI_ApiPm
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
exclude:
|
||||
- master
|
||||
|
||||
steps:
|
||||
- name: retore & build
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- dotnet build WF_EF_Api/WF_EF_Api.sln --configuration Release
|
||||
depend_on: [clone]
|
||||
|
||||
- name: test
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- dotnet test WF_EF_Api/XUnitTest/XUnitTest.csproj
|
||||
depends_on: [retore & build]
|
||||
|
||||
- name: publish
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- dotnet publish WF_EF_Api/WfApi/WfApi.csproj -c Release -o out
|
||||
depends_on: [retore & build, test]
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: CI_ApiPm_Master
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
- master
|
||||
|
||||
volumes:
|
||||
- name: doc
|
||||
temp: {}
|
||||
|
||||
|
||||
steps:
|
||||
- name: retore & build
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- dotnet build --configuration Release
|
||||
depend_on: [clone]
|
||||
|
||||
- name: test
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- dotnet test
|
||||
depends_on: [retore & build]
|
||||
|
||||
- name: generate doc
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
volumes:
|
||||
- name: doc
|
||||
path: /doc
|
||||
commands:
|
||||
- dotnet new tool-manifest
|
||||
- dotnet tool install NSwag.ConsoleCore
|
||||
- dotnet restore
|
||||
- cd WF_EF_Api/WfApi
|
||||
- dotnet nswag aspnetcore2openapi /output:/doc/swagger.json
|
||||
depends_on: [clone, retore & build]
|
||||
|
||||
#- name: code-inspection
|
||||
# image: hub.codefirst.iut.uca.fr/marc.chevaldonne:codefirs-dronsonarplugin-dotnet8
|
||||
# secret: [SECRET_SONAR_LOGIN]
|
||||
# A FINIR
|
||||
- name: publish
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- dotnet publish -c Release -o out
|
||||
depends_on: [retore & build, test]
|
@ -1,2 +1,59 @@
|
||||
# WF-PmAPI
|
||||
|
||||
|
||||
### Paquets
|
||||
NSwag.AspNetCore <br>
|
||||
Moq
|
||||
|
||||
🟨 En cours / ✅ Fait / ❌ Pas fait
|
||||
|
||||
### Critères Entity Framework
|
||||
|
||||
niveau | description | coeff | jalon | État
|
||||
--- | --- | --- | --- | ---
|
||||
☢️ | Le dépôt doit être accessible par l'enseignant | ☢️ | J1 | ✅
|
||||
☢️ | un .gitignore doit exister au premier push | ☢️ | J1 | ✅
|
||||
🎬 | les *projets* et les tests compilent | 1 | J1 & J2 | ✅
|
||||
🎬 | le projet et le tests s'exécutent sans bug (concernant la partie persistance) | 3 | J1 & J2 | ✅
|
||||
🟢 | Transcription du modèle : Modèle vers entités (et inversement) | 2 | J1 | ✅
|
||||
🟢 | Requêtes CRUD simples (sur une table) | 1 | J1 | ✅
|
||||
🟢 | Utilisation de LINQ to Entities | 2 | J1 | ✅
|
||||
🟡 | Injection / indépendance du fournisseur | 1 | J1 | ✅
|
||||
🟡 | Requêtes CRUD sur des données complexes (images par exemple) | 2 | J1 | ✅
|
||||
🟢 | Tests - Appli Console | 1 | J1 | ✅
|
||||
🟢 | Tests - Tests unitaires (avec SQLite in memory) | 2 | J1 | ❌
|
||||
🟢 | Tests - Données stubbées et/ou Moq | 1 | J1 | ✅
|
||||
🟡 | CI : build, tests, Sonar (doc?) | 1 | J1 | ❌
|
||||
🟡 | Utilisation de relations (One-to-One, One-to-Many, Many-to-Many) (+ mapping, TU, Requêtes) | 4 | J1 | ✅
|
||||
🟢 | Liens avec le web service | 2 | J1 | ✅
|
||||
🟡 | Utilisation d'un *Logger* | 1 | J1 | ❌
|
||||
🟡 | Déploiement | 4 | J2 | ❌
|
||||
🔴 | Unit of Work❌ / Repository✅ + extras (héritage, accès concurrents...) | 8 | J2 | 🟨
|
||||
🟢 | Utilisation dans le projet | 2 | J2 | ❌
|
||||
🟢 | mon dépôt possède un readme qui apporte quelque chose... | 2 | J2 | ✅
|
||||
|
||||
|
||||
### Critères Web API
|
||||
|
||||
niveau | description | coeff | jalon | État
|
||||
--- | --- | --- | --- | ---
|
||||
☢️ | Le dépôt doit être accessible par l'enseignant | ☢️ | J1 | ✅
|
||||
☢️ | un .gitignore doit exister au premier push | ☢️ | J1 | ✅
|
||||
🎬 | les *projets* et les tests compilent | 1 | J1 & J2 | ✅
|
||||
🎬 | le projet et le tests s'exécutent sans bug (concernant la partie web api) | 4 | J1 & J2 | ✅
|
||||
🟢 | Modèle <-> DTO | 1 | J1 | ❌
|
||||
🟢 | Entities <-> DTO | 1 | J1 | ✅
|
||||
🟡 | Authentification | 4 | J1 |
|
||||
🟢 | Requêtes GET, PUT, POST, DELETE sur des données simples (1 seul type d'objet en retour, propriétés de types natifs) | 2 | J1 | ✅
|
||||
🟡 | Pagination & filtrage | 2 | J1 | ✅
|
||||
🟢 | Injection de service | 2 | J1 | ✅
|
||||
🟡 | Requêtes GET, PUT, POST, DELETE sur des données complexes (plusieurs données complexes en retour) | 4 | J1 | 🟨
|
||||
🟢 | Tests - Appli Console (consommation des requêtes) | 4 | J1 | 🟨
|
||||
🟢 | Tests - Tests unitaires (avec Stub et/ou Moq) | 2 | J1 | ❌
|
||||
🟡 | CI : build, tests, Sonar, Documentation (en particulier Swagger avec exemples...) | 1 | J1 | ❌
|
||||
🟢 | Liens avec la persistance en base de données | 4 | J1 | ✅
|
||||
🟡 | Utilisation d'un *Logger* | 1 | J1 | ❌
|
||||
🟡 | Déploiement | 4 | J2 | ❌
|
||||
🟡 | Utilisation dans le projet | 4 | J2 | ❌
|
||||
🎬 | mon dépôt possède un readme qui apporte quelque chose... | 1 | J2 | ✅
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*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
|
||||
!**/.gitignore
|
||||
!.git/HEAD
|
||||
!.git/config
|
||||
!.git/packed-refs
|
||||
!.git/refs/heads/**
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,90 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34723.18
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTest", "ConsoleTest\ConsoleTest.csproj", "{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{792EF125-E2D4-457C-B536-BDAEFB49D14E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entity", "Entity\Entity.csproj", "{69A4450C-AA43-4622-A866-9A5F7C8A2C14}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contextlib", "Contextlib\Contextlib.csproj", "{32977454-CE94-4532-AE26-29F6951B78CF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{5CD69B14-C6AE-4628-A374-996C486E25F2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestModel2Entities", "TestModel2Entities\TestModel2Entities.csproj", "{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XUnitTest", "XUnitTest\XUnitTest.csproj", "{48002CA2-7CFF-4077-90CF-392476320CE3}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WfApi", "WfApi\WfApi.csproj", "{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubApi", "StubApi\StubApi.csproj", "{4C5F324C-28C3-4153-B402-A07B099C24C6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{99F43B70-4143-4807-9EE7-B8A799B1E702}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dto2Entities", "Dto2Entities\Dto2Entities.csproj", "{08194729-E222-4C9A-B860-D944225B8895}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServicesApi", "ServicesApi\ServicesApi.csproj", "{6A9AC3D2-C1CD-450A-BD3C-22FAFC9B5328}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A8B0E4D8-0726-4248-BB6D-DAA2545270B1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{792EF125-E2D4-457C-B536-BDAEFB49D14E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{69A4450C-AA43-4622-A866-9A5F7C8A2C14}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32977454-CE94-4532-AE26-29F6951B78CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{32977454-CE94-4532-AE26-29F6951B78CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{32977454-CE94-4532-AE26-29F6951B78CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{32977454-CE94-4532-AE26-29F6951B78CF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5CD69B14-C6AE-4628-A374-996C486E25F2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48002CA2-7CFF-4077-90CF-392476320CE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48002CA2-7CFF-4077-90CF-392476320CE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48002CA2-7CFF-4077-90CF-392476320CE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48002CA2-7CFF-4077-90CF-392476320CE3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D4EEE1BF-CDCB-4E66-997B-7A5984DA7995}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4C5F324C-28C3-4153-B402-A07B099C24C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4C5F324C-28C3-4153-B402-A07B099C24C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4C5F324C-28C3-4153-B402-A07B099C24C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4C5F324C-28C3-4153-B402-A07B099C24C6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{99F43B70-4143-4807-9EE7-B8A799B1E702}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{99F43B70-4143-4807-9EE7-B8A799B1E702}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{99F43B70-4143-4807-9EE7-B8A799B1E702}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{99F43B70-4143-4807-9EE7-B8A799B1E702}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{08194729-E222-4C9A-B860-D944225B8895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{08194729-E222-4C9A-B860-D944225B8895}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{08194729-E222-4C9A-B860-D944225B8895}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{08194729-E222-4C9A-B860-D944225B8895}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6A9AC3D2-C1CD-450A-BD3C-22FAFC9B5328}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6A9AC3D2-C1CD-450A-BD3C-22FAFC9B5328}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6A9AC3D2-C1CD-450A-BD3C-22FAFC9B5328}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6A9AC3D2-C1CD-450A-BD3C-22FAFC9B5328}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {EC43AAEE-68F6-4CA2-A195-14A91E7D53C0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -0,0 +1,25 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["WfApi/WfApi.csproj", "WfApi/"]
|
||||
RUN dotnet restore "./WfApi/WfApi.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/WfApi"
|
||||
RUN dotnet build "./WfApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./WfApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "WfApi.dll"]
|
@ -0,0 +1,83 @@
|
||||
using DTO;
|
||||
using Shared;
|
||||
using StubApi;
|
||||
using Contextlib;
|
||||
using Entity;
|
||||
using StubbedContextLib;
|
||||
using ServicesApi;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
//API
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddScoped<IUserService<UserDTO>, UserService>();
|
||||
builder.Services.AddScoped<IQuoteService<QuoteDTO>, QuoteService>();
|
||||
builder.Services.AddScoped<IFavoriteService<QuoteDTO>, FavoriteService>();
|
||||
builder.Services.AddScoped<ICommentaryService<CommentaryDTO>, CommentaryService>();
|
||||
builder.Services.AddScoped<ICharacterService<CharacterDTO>, CharacterService>();
|
||||
builder.Services.AddScoped<IImagesService<ImageDTO>, ImageService>();
|
||||
builder.Services.AddScoped<ISourceService<SourceDTO>, SourceService>();
|
||||
builder.Services.AddScoped<IQuestionService<QuestionDTO>, QuestionService>();
|
||||
|
||||
|
||||
//EF
|
||||
builder.Services.AddScoped<WTFContext, StubWTFContext>();
|
||||
|
||||
|
||||
builder.Services.AddScoped<IUserService<Users>, DbUsersManager>();
|
||||
builder.Services.AddScoped<IQuoteService<Quote>, DbQuoteManager>();
|
||||
builder.Services.AddScoped<IFavoriteService<Quote>, DbFavoriteManager>();
|
||||
builder.Services.AddScoped<ICommentaryService<Commentary>, DbCommentaryManager>();
|
||||
builder.Services.AddScoped<ICharacterService<Character>, DbCharacterManager>();
|
||||
builder.Services.AddScoped<IImagesService<Images>, DbImagesManager>();
|
||||
builder.Services.AddScoped<ISourceService<Source>, DbSourceManager>();
|
||||
builder.Services.AddScoped<IQuestionService<Question>, DbQuestionManager>();
|
||||
//...
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddOpenApiDocument(options => {
|
||||
options.PostProcess = document =>
|
||||
{
|
||||
document.Info = new NSwag.OpenApiInfo
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "What The Fantasy's API",
|
||||
Description = "What The Fantasy Site API",
|
||||
TermsOfService = "",
|
||||
Contact = new NSwag.OpenApiContact
|
||||
{
|
||||
Name = "The PM Mobile What The Fantasy team",
|
||||
Url = ""
|
||||
},
|
||||
License = new NSwag.OpenApiLicense
|
||||
{
|
||||
Name = "No license",
|
||||
Url = "https://license.fr"
|
||||
}
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseOpenApi(); // Active la documentation OpenAPI
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
@ -0,0 +1,52 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5239"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7250;http://localhost:5239"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:23612",
|
||||
"sslPort": 44320
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>283a610b-b95e-4b09-af22-b7d3270a917d</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
||||
<PackageReference Include="NSwag.AspNetCore" Version="14.2.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Contextlib\Contextlib.csproj" />
|
||||
<ProjectReference Include="..\DTO\DTO.csproj" />
|
||||
<ProjectReference Include="..\Entity\Entity.csproj" />
|
||||
<ProjectReference Include="..\ServicesApi\ServicesApi.csproj" />
|
||||
<ProjectReference Include="..\Shared\Shared.csproj" />
|
||||
<ProjectReference Include="..\StubApi\StubApi.csproj" />
|
||||
<ProjectReference Include="..\StubbedContextLib\StubbedContextLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,6 @@
|
||||
@WfApi_HostAddress = http://localhost:5239
|
||||
|
||||
GET {{WfApi_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
@ -0,0 +1,283 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
|
||||
|
||||
using WfApi.Controllers;
|
||||
using Shared;
|
||||
using DTO;
|
||||
|
||||
namespace XUnitTest
|
||||
{
|
||||
public class UnitTest1
|
||||
{
|
||||
//private readonly Mock<IUserService<UserDTO>> _mockUserService;
|
||||
//private readonly Mock<ILogger<UsersController>> _mockLogger;
|
||||
//private readonly UsersController _userController;
|
||||
|
||||
//public UnitTest1()
|
||||
//{
|
||||
// // Initialisation des mocks
|
||||
// _mockUserService = new Mock<IUserService<UserDTO>>();
|
||||
// _mockLogger = new Mock<ILogger<UsersController>>();
|
||||
// _userController = new UsersController(_mockUserService.Object, _mockLogger.Object);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//[Fact]
|
||||
//public async Task Get_ReturnsOk_WhenUserExists()
|
||||
//{
|
||||
// // Arrange
|
||||
// var userId = 1;
|
||||
// var userDTO = new UserDTO
|
||||
// {
|
||||
// Id = userId,
|
||||
// Pseudo = "test",
|
||||
// Email = "test@unitaire.fr",
|
||||
// ImageProfil = "http://test",
|
||||
// Password = "1234"
|
||||
// };
|
||||
|
||||
// _mockUserService.Setup(service => service.GetUserById(userId)).ReturnsAsync(userDTO);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.Get(userId);
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
//[Fact]
|
||||
//public async Task GetAllUsers_ReturnsOk()
|
||||
//{
|
||||
// // Arrange
|
||||
// var userDTO = new UserDTO
|
||||
// {
|
||||
// Id = 1,
|
||||
// Pseudo = "test",
|
||||
// Email = "test@unitaire.fr",
|
||||
// ImageProfil = "http://test",
|
||||
// Password = "1234"
|
||||
// };
|
||||
// var userDTO2 = new UserDTO
|
||||
// {
|
||||
// Id = 2,
|
||||
// Pseudo = "test",
|
||||
// Email = "test@unitaire.fr",
|
||||
// ImageProfil = "http://test",
|
||||
// Password = "1234"
|
||||
// };
|
||||
|
||||
// _mockUserService.Setup(service => service.GetUserById(1)).ReturnsAsync(userDTO);
|
||||
// _mockUserService.Setup(service => service.GetUserById(2)).ReturnsAsync(userDTO);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.GetAllUsers();
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//[Fact]
|
||||
//public async Task GetHashPassword_ReturnsOk_WhenPasswordHashIsFound()
|
||||
//{
|
||||
// // Arrange
|
||||
// var username = "testUser";
|
||||
// var expectedHash = "hashedPassword";
|
||||
|
||||
// var taskResult = Task.FromResult(expectedHash);
|
||||
// _mockUserService.Setup(service => service.GetHashPassword(username)).Returns(taskResult);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.GetHashPassword(username);
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public async Task GetUserByUsername_ReturnsOk_WhenPasswordHashIsFound()
|
||||
//{
|
||||
// // Arrange
|
||||
// var username = "testUser";
|
||||
// var userDTO = new UserDTO
|
||||
// {
|
||||
// Id = 1,
|
||||
// Pseudo = "testUser",
|
||||
// Email = "test@unitaire.fr",
|
||||
// ImageProfil = "http://test",
|
||||
// Password = "1234"
|
||||
// };
|
||||
|
||||
// var taskResult = Task.FromResult(userDTO);
|
||||
// _mockUserService.Setup(service => service.GetUserByUsername(username)).Returns(taskResult);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.GetUserByUsername(username);
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public async Task GetUserByEmail_ReturnsOk_WhenUserExists()
|
||||
//{
|
||||
// // Arrange
|
||||
// var email = "test@unitaire.fr";
|
||||
// var userDTO = new UserDTO
|
||||
// {
|
||||
// Id = 1,
|
||||
// Pseudo = "testUser",
|
||||
// Email = email,
|
||||
// ImageProfil = "http://test",
|
||||
// Password = "1234"
|
||||
// };
|
||||
|
||||
|
||||
// var taskResult = Task.FromResult(userDTO);
|
||||
// _mockUserService.Setup(service => service.GetUserByEmail(email)).Returns(taskResult);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.GetUserByEmail(email);
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public async Task GetCountUser_ReturnsOk_WhenCountIsSuccessful()
|
||||
//{
|
||||
// // Arrange
|
||||
// var expectedCount = 5;
|
||||
// var taskResult = Task.FromResult(expectedCount);
|
||||
|
||||
// _mockUserService.Setup(service => service.CountUser()).Returns(taskResult);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.GetCountUser();
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public async Task GetExistUsername_ReturnsOk_WhenUserExists()
|
||||
//{
|
||||
// // Arrange
|
||||
// var username = "testUser";
|
||||
// var taskResult = Task.FromResult(true);
|
||||
|
||||
|
||||
// _mockUserService.Setup(service => service.ExistUsername(username)).Returns(taskResult);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.GetExistUsername(username);
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public async Task GetExistEmail_ReturnsOk_WhenEmailExists()
|
||||
//{
|
||||
// // Arrange
|
||||
// var email = "test@unitaire.fr";
|
||||
// var taskResult = Task.FromResult(true);
|
||||
|
||||
// _mockUserService.Setup(service => service.ExistEmail(email)).Returns(taskResult);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.GetExistEmail(email);
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
|
||||
//}
|
||||
//[Fact]
|
||||
//public async Task UpdateUser_ReturnsOk_WhenUserDataIsValid()
|
||||
//{
|
||||
// // Arrange
|
||||
// var id = 1;
|
||||
// var updatedUser = new UserDTO
|
||||
// {
|
||||
// Id = id,
|
||||
// Pseudo = "UpdatedUser",
|
||||
// Email = "updated@unitaire.fr",
|
||||
// ImageProfil = "http://updatedImage.com",
|
||||
// Password = "newPassword123"
|
||||
// };
|
||||
|
||||
// var taskResult = Task.FromResult(updatedUser);
|
||||
|
||||
// _mockUserService.Setup(service => service.UpdateUser(id, updatedUser)).Returns(taskResult);
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.UpdateUser(id, updatedUser);
|
||||
|
||||
// // Assert
|
||||
// var okResult = Assert.IsType<OkObjectResult>(result);
|
||||
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
//}
|
||||
//[Fact]
|
||||
//public async Task CreateUser_ReturnsCreatedAtAction_WhenUserIsValid()
|
||||
//{
|
||||
// // Arrange
|
||||
// var newUser = new UserDTO
|
||||
// {
|
||||
// Id = 2,
|
||||
// Pseudo = "NewUser",
|
||||
// Email = "newuser@unitaire.fr",
|
||||
// ImageProfil = "http://newuserimage.com",
|
||||
// Password = "newPassword123"
|
||||
// };
|
||||
|
||||
// _mockUserService.Setup(service => service.GetUserById(newUser.Id)).ReturnsAsync((UserDTO)null);
|
||||
|
||||
// _mockUserService.Setup(service => service.AddUser(newUser)).Verifiable();
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.CreateUser(newUser);
|
||||
|
||||
// // Assert
|
||||
// var createdResult = Assert.IsType<CreatedAtActionResult>(result);
|
||||
// Assert.Equal(newUser.Id, createdResult.RouteValues["id"]);
|
||||
//}
|
||||
|
||||
|
||||
//[Fact]
|
||||
//public async Task DeletePlayer_ReturnsOk_WhenPlayerExists()
|
||||
//{
|
||||
// // Arrange
|
||||
// var id = 1;
|
||||
// var existingPlayer = new UserDTO
|
||||
// {
|
||||
// Id = id,
|
||||
// Pseudo = "ExistingUser",
|
||||
// Email = "existing@unitaire.fr",
|
||||
// ImageProfil = "http://existingimage.com",
|
||||
// Password = "existingPassword123"
|
||||
// };
|
||||
|
||||
// _mockUserService.Setup(service => service.GetUserById(id)).ReturnsAsync(existingPlayer);
|
||||
|
||||
// _mockUserService.Setup(service => service.RemoveUser(existingPlayer.Id)).Verifiable();
|
||||
|
||||
// // Act
|
||||
// var result = await _userController.DeletePlayer(id);
|
||||
|
||||
// // Assert
|
||||
// Assert.IsType<OkObjectResult>(result);
|
||||
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="xunit" Version="2.5.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DTO\DTO.csproj" />
|
||||
<ProjectReference Include="..\Shared\Shared.csproj" />
|
||||
<ProjectReference Include="..\WfApi\WfApi.csproj" />
|
||||
<ProjectReference Include="..\StubbedContextLib\StubbedContextLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in new issue