Compare commits
109 Commits
@ -0,0 +1,64 @@ |
||||
using System.Collections.Generic; |
||||
using espacecollab.backend.api.Controllers; |
||||
using espacecollab.backend.appservices.dtos.Interfaces; |
||||
using FluentAssertions; |
||||
using Microsoft.AspNetCore.Mvc; |
||||
using Xunit; |
||||
|
||||
namespace espacecollab.backend.api.tests; |
||||
|
||||
public abstract class BaseControllerTest<T, TO> where T : IBaseController<TO> |
||||
where TO : class, IGenericIdApiDto |
||||
{ |
||||
protected T Controller { get; set; } |
||||
protected TO NewApiDo { get; set; } |
||||
protected TO UpdateApiDo { get; set; } |
||||
|
||||
[Fact] |
||||
public void GetAllTest() |
||||
{ |
||||
ActionResult<IEnumerable<TO>> actionResult = Controller.GetAll(); |
||||
|
||||
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject; |
||||
result.Value.Should().BeOfType<List<TO>>(); |
||||
} |
||||
|
||||
[Fact] |
||||
public void GetByIdTest() |
||||
{ |
||||
uint id = 1; |
||||
|
||||
ActionResult<TO> actionResult = Controller.GetById(id); |
||||
|
||||
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject; |
||||
result.Value.Should().BeOfType<TO>(); |
||||
} |
||||
|
||||
[Fact] |
||||
public void AddTest() |
||||
{ |
||||
ActionResult<TO> actionResult = Controller.Add(NewApiDo); |
||||
|
||||
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject; |
||||
result.Value.Should().BeOfType<TO>().Subject.Id.Should().NotBe(0); |
||||
} |
||||
|
||||
[Fact] |
||||
public void DeleteTest() |
||||
{ |
||||
uint id = 1; |
||||
|
||||
ActionResult<TO> actionResult = Controller.Delete(id); |
||||
|
||||
actionResult.Result.Should().BeOfType<OkResult>(); |
||||
} |
||||
|
||||
[Fact] |
||||
public void UpdateTest() |
||||
{ |
||||
ActionResult<TO> actionResult = Controller.Update(UpdateApiDo.Id, UpdateApiDo); |
||||
|
||||
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject; |
||||
result.Value.Should().BeOfType<TO>().Subject.Id.Should().Be(UpdateApiDo.Id); |
||||
} |
||||
} |
@ -0,0 +1,28 @@ |
||||
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
||||
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
||||
<Nullable>enable</Nullable> |
||||
|
||||
<IsPackable>false</IsPackable> |
||||
</PropertyGroup> |
||||
|
||||
<ItemGroup> |
||||
<PackageReference Include="FluentAssertions" Version="6.7.0" /> |
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> |
||||
<PackageReference Include="xunit" Version="2.4.1" /> |
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> |
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
<PrivateAssets>all</PrivateAssets> |
||||
</PackageReference> |
||||
<PackageReference Include="coverlet.collector" Version="3.1.2"> |
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
<PrivateAssets>all</PrivateAssets> |
||||
</PackageReference> |
||||
</ItemGroup> |
||||
|
||||
<ItemGroup> |
||||
<ProjectReference Include="..\espacecollab.backend.api\espacecollab.backend.api.csproj" /> |
||||
</ItemGroup> |
||||
|
||||
</Project> |
@ -0,0 +1,29 @@ |
||||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. |
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base |
||||
WORKDIR /app |
||||
EXPOSE 80 |
||||
EXPOSE 443 |
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build |
||||
WORKDIR /src |
||||
COPY ["espacecollab.backend.api/espacecollab.backend.api.csproj", "espacecollab.backend.api/"] |
||||
COPY ["espacecollab.backend.appservices/espacecollab.backend.appservices.csproj", "espacecollab.backend.appservices/"] |
||||
COPY ["espacecollab.backend.appservices.dtos/espacecollab.backend.appservices.dtos.csproj", "espacecollab.backend.appservices.dtos/"] |
||||
COPY ["espacecollab.backend.infrastructure.sql.dtos/espacecollab.backend.infrastructure.sql.dtos.csproj", "espacecollab.backend.infrastructure.sql.dtos/"] |
||||
COPY ["espacecollab.backend.appservices.interfaces/espacecollab.backend.appservices.interfaces.csproj", "espacecollab.backend.appservices.interfaces/"] |
||||
COPY ["espacecollab.backend.infrastructure.sql/espacecollab.backend.infrastructure.sql.csproj", "espacecollab.backend.infrastructure.sql/"] |
||||
COPY ["espacecollab.backend.infrastructure.interfaces/espacecollab.backend.infrastructure.interfaces.csproj", "espacecollab.backend.infrastructure.interfaces/"] |
||||
COPY ["espacecollab.backend.infrastructure.fake/espacecollab.backend.infrastructure.fake.csproj", "espacecollab.backend.infrastructure.fake/"] |
||||
RUN dotnet restore "espacecollab.backend.api/espacecollab.backend.api.csproj" |
||||
COPY . . |
||||
WORKDIR "/src/espacecollab.backend.api" |
||||
RUN dotnet build "espacecollab.backend.api.csproj" -c Release -o /app/build |
||||
|
||||
FROM build AS publish |
||||
RUN dotnet publish "espacecollab.backend.api.csproj" -c Release -o /app/publish |
||||
|
||||
FROM base AS final |
||||
WORKDIR /app |
||||
COPY --from=publish /app/publish . |
||||
ENTRYPOINT ["dotnet", "espacecollab.backend.api.dll"] |
@ -0,0 +1,16 @@ |
||||
namespace espacecollab.backend.api; |
||||
|
||||
public static class Program |
||||
{ |
||||
public static void Main(string[] args) |
||||
{ |
||||
CreateHostBuilder(args).Build().Run(); |
||||
} |
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => |
||||
Host.CreateDefaultBuilder(args) |
||||
.ConfigureWebHostDefaults(webBuilder => |
||||
{ |
||||
webBuilder.UseStartup<Startup>(); |
||||
}); |
||||
} |
@ -0,0 +1,38 @@ |
||||
{ |
||||
"$schema": "https://json.schemastore.org/launchsettings.json", |
||||
"iisSettings": { |
||||
"windowsAuthentication": false, |
||||
"anonymousAuthentication": true, |
||||
"iisExpress": { |
||||
"applicationUrl": "http://localhost:27916", |
||||
"sslPort": 44341 |
||||
} |
||||
}, |
||||
"profiles": { |
||||
"espacecollab.backend.api": { |
||||
"commandName": "Project", |
||||
"launchBrowser": true, |
||||
"launchUrl": "swagger", |
||||
"environmentVariables": { |
||||
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
}, |
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000", |
||||
"dotnetRunMessages": true |
||||
}, |
||||
"IIS Express": { |
||||
"commandName": "IISExpress", |
||||
"launchBrowser": true, |
||||
"launchUrl": "swagger", |
||||
"environmentVariables": { |
||||
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
} |
||||
}, |
||||
"Docker": { |
||||
"commandName": "Docker", |
||||
"launchBrowser": true, |
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", |
||||
"publishAllPorts": true, |
||||
"useSSL": true |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
{ |
||||
"Logging": { |
||||
"LogLevel": { |
||||
"Default": "Information", |
||||
"Microsoft.AspNetCore": "Warning" |
||||
} |
||||
}, |
||||
"AllowedHosts": "*", |
||||
"Sql": { |
||||
"LoadFake": false, |
||||
"ConnectionString": "server=database;user=root;password=root;database=collaborateur_epa" //préprod |
||||
//"ConnectionString": "server=localhost;user=root;password=root;database=collaborateur_epa" //local |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
||||
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
||||
<ImplicitUsings>enable</ImplicitUsings> |
||||
<Nullable>enable</Nullable> |
||||
</PropertyGroup> |
||||
|
||||
<ItemGroup> |
||||
<ProjectReference Include="..\espacecollab.backend.appservices.dtos\espacecollab.backend.appservices.dtos.csproj" /> |
||||
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" /> |
||||
</ItemGroup> |
||||
|
||||
</Project> |
@ -0,0 +1,15 @@ |
||||
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
||||
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
||||
<ImplicitUsings>enable</ImplicitUsings> |
||||
<Nullable>enable</Nullable> |
||||
</PropertyGroup> |
||||
|
||||
<ItemGroup> |
||||
<ProjectReference Include="..\espacecollab.backend.appservices.dtos\espacecollab.backend.appservices.dtos.csproj" /> |
||||
<ProjectReference Include="..\espacecollab.backend.appservices.interfaces\espacecollab.backend.appservices.interfaces.csproj" /> |
||||
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql\espacecollab.backend.infrastructure.sql.csproj" /> |
||||
</ItemGroup> |
||||
|
||||
</Project> |
@ -0,0 +1,14 @@ |
||||
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
||||
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
||||
<ImplicitUsings>enable</ImplicitUsings> |
||||
<Nullable>enable</Nullable> |
||||
</PropertyGroup> |
||||
|
||||
<ItemGroup> |
||||
<ProjectReference Include="..\espacecollab.backend.infrastructure.interfaces\espacecollab.backend.infrastructure.interfaces.csproj" /> |
||||
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" /> |
||||
</ItemGroup> |
||||
|
||||
</Project> |
@ -0,0 +1,13 @@ |
||||
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
||||
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
||||
<ImplicitUsings>enable</ImplicitUsings> |
||||
<Nullable>enable</Nullable> |
||||
</PropertyGroup> |
||||
|
||||
<ItemGroup> |
||||
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" /> |
||||
</ItemGroup> |
||||
|
||||
</Project> |
@ -0,0 +1,9 @@ |
||||
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
||||
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
||||
<ImplicitUsings>enable</ImplicitUsings> |
||||
<Nullable>enable</Nullable> |
||||
</PropertyGroup> |
||||
|
||||
</Project> |
@ -0,0 +1,161 @@ |
||||
DROP DATABASE IF EXISTS collaborateur_epa; |
||||
CREATE DATABASE IF NOT EXISTS collaborateur_epa /*!40100 DEFAULT CHARACTER SET latin1 */; |
||||
USE collaborateur_epa; |
||||
|
||||
DROP TABLE IF EXISTS Agence; |
||||
CREATE TABLE IF NOT EXISTS Agence( |
||||
Id int NOT NULL AUTO_INCREMENT, |
||||
Name varchar(100) NOT NULL UNIQUE, |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS BusinessUnit; |
||||
CREATE TABLE IF NOT EXISTS BusinessUnit( |
||||
Id int NOT NULL AUTO_INCREMENT, |
||||
Name varchar(100) NOT NULL UNIQUE, |
||||
AgenceId int NOT NULL, |
||||
CONSTRAINT FK_BUSINESS_UNIT_AGENCE FOREIGN KEY (AgenceId) references Agence(Id), |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS Site; |
||||
CREATE TABLE IF NOT EXISTS Site( |
||||
Id int NOT NULL AUTO_INCREMENT, |
||||
Name varchar(100) NOT NULL UNIQUE, |
||||
Address varchar(200) NOT NULL, |
||||
BusinessUnitId int NOT NULL, |
||||
CONSTRAINT FK_SITE_BUSINESS_UNIT FOREIGN KEY (BusinessUnitId) references BusinessUnit(Id), |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS Projet; |
||||
CREATE TABLE IF NOT EXISTS Projet( |
||||
Id int NOT NULL AUTO_INCREMENT, |
||||
Name varchar(100) NOT NULL UNIQUE, |
||||
Client varchar(100) NOT NULL, |
||||
Description varchar(100) NOT NULL, |
||||
StartingDate date NOT NULL, |
||||
EndingDate date NOT NULL, |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS Technologie; |
||||
CREATE TABLE IF NOT EXISTS Technologie( |
||||
Id int NOT NULL UNIQUE, |
||||
Name varchar(100) NOT NULL UNIQUE, |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS Fonction; |
||||
CREATE TABLE IF NOT EXISTS Fonction( |
||||
Id int NOT NULL UNIQUE, |
||||
intitule varchar(100) NOT NULL UNIQUE, |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS Collaborateur; |
||||
CREATE TABLE IF NOT EXISTS Collaborateur( |
||||
Id int NOT NULL AUTO_INCREMENT, |
||||
Name varchar(100) NOT NULL, |
||||
FirstName varchar(100) NOT NULL, |
||||
BirthDate date NOT NULL, |
||||
Gender ENUM('masculin','feminin','autre') NOT NULL DEFAULT 'masculin', |
||||
Status ENUM('cadre','noncadre','alternant','stagiaire') NOT NULL DEFAULT 'noncadre', |
||||
ChildrenNumber smallint NOT NULL, |
||||
Address varchar(200) NOT NULL, |
||||
Telephone varchar(15) NOT NULL, |
||||
PersonalMail varchar(100) NOT NULL, |
||||
ApsideMail varchar(100) NOT NULL, |
||||
ResignationDate date, |
||||
BusinessUnitId int NOT NUll, |
||||
ReferrerId int, |
||||
CONSTRAINT FK_COLLABORATEUR_BUSINESSUNIT FOREIGN KEY (BusinessUnitId) REFERENCES BusinessUnit(Id), |
||||
CONSTRAINT FK_COLLABORATEUR_PARRAIN FOREIGN KEY (ReferrerId) REFERENCES Collaborateur(Id), |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS PeriodeEssai; |
||||
CREATE TABLE IF NOT EXISTS PeriodeEssai( |
||||
Id int NOT NULL AUTO_INCREMENT, |
||||
StartingDate date NOT NULL, |
||||
PlannedEndingDate date NOT NULL, |
||||
RealEndingDate date NOT NULL, |
||||
Comment varchar(100) NOT NULL, |
||||
Issue ENUM('VALIDEE','PROLONGEE_COLLAB','PROLONGEE_APSIDE','ARRETEE_COLLAB','ARRETEE_APSIDE') NOT NULL, |
||||
CollaborateurId int NOT NULL, |
||||
CONSTRAINT FK_COLLABORATEUR_PERIODEESSAI FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id), |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS Referencement; |
||||
CREATE TABLE IF NOT EXISTS Referencement( |
||||
Id int NOT NULL AUTO_INCREMENT, |
||||
StartingDate date NOT NULL, |
||||
EndingDate date NOT NULL, |
||||
ReferredId int NOT NULL, |
||||
ReferrerId int NOT NULL, |
||||
CONSTRAINT FK_COLLABORATEUR_REFERE FOREIGN KEY (ReferredId) REFERENCES Collaborateur(Id), |
||||
CONSTRAINT FK_COLLABORATEUR_REFERENT FOREIGN KEY (ReferrerId) REFERENCES Collaborateur(Id), |
||||
PRIMARY KEY (Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS CollaborateurEstFonction; |
||||
CREATE TABLE IF NOT EXISTS CollaborateurEstFonction( |
||||
CollaborateurId int NOT NULL, |
||||
FonctionId int NOT NULL, |
||||
PRIMARY KEY (CollaborateurId,FonctionId), |
||||
CONSTRAINT FK_COLLABORATEUR_FONCTION FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id), |
||||
CONSTRAINT FK_FONCTION_COLLABORATEUR FOREIGN KEY (FonctionId) REFERENCES Fonction(Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS CollaborateurAppartientBusinessUnit; |
||||
CREATE TABLE IF NOT EXISTS CollaborateurAppartientBusinessUnit( |
||||
CollaborateurId int NOT NULL, |
||||
BusinessUnitId int NOT NULL, |
||||
PRIMARY KEY (CollaborateurId,BusinessUnitId), |
||||
CONSTRAINT FK_COLLABORATEUR_BUSINESS_UNIT FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id), |
||||
CONSTRAINT FK_BUSINESS_UNIT_COLLABORATEUR FOREIGN KEY (BusinessUnitId) REFERENCES BusinessUnit(Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS CollaborateurEffectuePeriodeEssai; |
||||
CREATE TABLE IF NOT EXISTS CollaborateurEffectuePeriodeEssai( |
||||
CollaborateurId int NOT NULL, |
||||
PeriodeEssaiId int NOT NULL, |
||||
PRIMARY KEY (CollaborateurId,PeriodeEssaiId), |
||||
CONSTRAINT FK_COLLABORATEUR_PERIODE_ESSAI FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id), |
||||
CONSTRAINT FK_PERIODE_ESSAI_COLLABORATEUR FOREIGN KEY (PeriodeEssaiId) REFERENCES PeriodeEssai(Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS SiteDeveloppeProjet; |
||||
CREATE TABLE IF NOT EXISTS SiteDeveloppeProjet( |
||||
SiteId int NOT NULL, |
||||
ProjetId int NOT NULL, |
||||
PRIMARY KEY (SiteId,ProjetId), |
||||
CONSTRAINT FK_SITE_PROJET FOREIGN KEY (SiteId) REFERENCES Site(Id), |
||||
CONSTRAINT FK_PROJET_SITE FOREIGN KEY (ProjetId) REFERENCES Projet(Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS ProjetUtiliseTechnologie; |
||||
CREATE TABLE IF NOT EXISTS ProjetUtiliseTechnologie( |
||||
ProjetId int NOT NULL, |
||||
TechnologieId int NOT NULL, |
||||
PRIMARY KEY (ProjetId,TechnologieId), |
||||
CONSTRAINT FK_PROJET_TECHNOLOGIE FOREIGN KEY (ProjetId) REFERENCES Projet(Id), |
||||
CONSTRAINT FK_TECHNOLOGIE_PROJET FOREIGN KEY (TechnologieId) REFERENCES Technologie(Id) |
||||
); |
||||
|
||||
DROP TABLE IF EXISTS CollaborateurCollaboreProjet; |
||||
CREATE TABLE IF NOT EXISTS CollaborateurCollaboreProjet( |
||||
CollaborateurId int NOT NULL, |
||||
ProjetId int NOT NULL, |
||||
isManager boolean NOT NULL, |
||||
PRIMARY KEY (CollaborateurId,ProjetId), |
||||
CONSTRAINT FK_COLLABORATEUR_COLLABORE_PROJET FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id), |
||||
CONSTRAINT FK_PROJET_COLLABORE_COLLABORATEUR FOREIGN KEY (ProjetId) REFERENCES Projet(Id) |
||||
); |
||||
|
||||
INSERT INTO Agence(Id, Name) VALUES (1,'Agence1'); |
||||
INSERT INTO BusinessUnit(Id, Name, AgenceId) VALUES (1,'BusinessUnit1',1); |
||||
INSERT INTO Collaborateur(Id, Name, FirstName, BirthDate, Gender, Status, ChildrenNumber, Address, Telephone, PersonalMail, |
||||
ApsideMail, ResignationDate, BusinessUnitId, ReferrerId) |
||||
VALUES (1,'Collab1','Collab1','2000-30-08','masculin','cadre',0,'adresse','tel','pmail','amail',NULL,1,NULL); |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue