Parcourir la source

First commit

master
Christophe Brachet il y a 3 mois
Parent
révision
6ded43c514
36 fichiers modifiés avec 1345 ajouts et 0 suppressions
  1. BIN
      TestApiDocker/.vs/ProjectEvaluation/testapidocker.metadata.v9.bin
  2. BIN
      TestApiDocker/.vs/ProjectEvaluation/testapidocker.projects.v9.bin
  3. BIN
      TestApiDocker/.vs/ProjectEvaluation/testapidocker.strings.v9.bin
  4. BIN
      TestApiDocker/.vs/TestApiDocker/DesignTimeBuild/.dtbcache.v2
  5. BIN
      TestApiDocker/.vs/TestApiDocker/FileContentIndex/0ecca3b2-8a3a-46cf-a395-e34b70210297.vsidx
  6. BIN
      TestApiDocker/.vs/TestApiDocker/FileContentIndex/36161c2e-0232-4ce5-8655-2fce7ed6611d.vsidx
  7. BIN
      TestApiDocker/.vs/TestApiDocker/FileContentIndex/4e348622-10ba-4e3d-ab78-7d1c88b60bae.vsidx
  8. BIN
      TestApiDocker/.vs/TestApiDocker/FileContentIndex/63382ed3-2aab-46a3-9918-3912b67dca14.vsidx
  9. BIN
      TestApiDocker/.vs/TestApiDocker/FileContentIndex/f8844ff9-9ecf-4211-af3c-0079b87524fb.vsidx
  10. BIN
      TestApiDocker/.vs/TestApiDocker/v17/.futdcache.v2
  11. BIN
      TestApiDocker/.vs/TestApiDocker/v17/.suo
  12. +12
    -0
      TestApiDocker/.vs/TestApiDocker/v17/DocumentLayout.backup.json
  13. +54
    -0
      TestApiDocker/.vs/TestApiDocker/v17/DocumentLayout.json
  14. BIN
      TestApiDocker/.vs/TestApiDocker/v17/TestStore/0/000.testlog
  15. BIN
      TestApiDocker/.vs/TestApiDocker/v17/TestStore/0/testlog.manifest
  16. BIN
      TestApiDocker/.vs/TestApiDocker/v17/TestStore/1/000.testlog
  17. BIN
      TestApiDocker/.vs/TestApiDocker/v17/TestStore/1/testlog.manifest
  18. +25
    -0
      TestApiDocker/TestApiDocker.sln
  19. +16
    -0
      TestApiDocker/TestApiDocker/Models/WeatherForecast.cs
  20. +53
    -0
      TestApiDocker/TestApiDocker/MyUnitTest.cs
  21. +24
    -0
      TestApiDocker/TestApiDocker/TestApiDocker.csproj
  22. BIN
      docker-dotnetcore-api/.vs/docker-dotnetcore-api/DesignTimeBuild/.dtbcache.v2
  23. BIN
      docker-dotnetcore-api/.vs/docker-dotnetcore-api/FileContentIndex/85f069ee-3b06-4203-af6f-d66c82b9183c.vsidx
  24. +1016
    -0
      docker-dotnetcore-api/.vs/docker-dotnetcore-api/config/applicationhost.config
  25. BIN
      docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/.futdcache.v2
  26. BIN
      docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/.suo
  27. BIN
      docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/TestStore/0/000.testlog
  28. BIN
      docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/TestStore/0/testlog.manifest
  29. +16
    -0
      docker-dotnetcore-api/Dockerfile
  30. +44
    -0
      docker-dotnetcore-api/Program.cs
  31. +41
    -0
      docker-dotnetcore-api/Properties/launchSettings.json
  32. +8
    -0
      docker-dotnetcore-api/appsettings.Development.json
  33. +9
    -0
      docker-dotnetcore-api/appsettings.json
  34. +15
    -0
      docker-dotnetcore-api/docker-dotnetcore-api.csproj
  35. +6
    -0
      docker-dotnetcore-api/docker-dotnetcore-api.csproj.user
  36. +6
    -0
      docker-dotnetcore-api/docker-dotnetcore-api.http

BIN
TestApiDocker/.vs/ProjectEvaluation/testapidocker.metadata.v9.bin Voir le fichier


BIN
TestApiDocker/.vs/ProjectEvaluation/testapidocker.projects.v9.bin Voir le fichier


BIN
TestApiDocker/.vs/ProjectEvaluation/testapidocker.strings.v9.bin Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/DesignTimeBuild/.dtbcache.v2 Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/FileContentIndex/0ecca3b2-8a3a-46cf-a395-e34b70210297.vsidx Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/FileContentIndex/36161c2e-0232-4ce5-8655-2fce7ed6611d.vsidx Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/FileContentIndex/4e348622-10ba-4e3d-ab78-7d1c88b60bae.vsidx Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/FileContentIndex/63382ed3-2aab-46a3-9918-3912b67dca14.vsidx Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/FileContentIndex/f8844ff9-9ecf-4211-af3c-0079b87524fb.vsidx Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/v17/.futdcache.v2 Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/v17/.suo Voir le fichier


+ 12
- 0
TestApiDocker/.vs/TestApiDocker/v17/DocumentLayout.backup.json Voir le fichier

@@ -0,0 +1,12 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\christophe_brachet\\Desktop\\TestApiDocker\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}

+ 54
- 0
TestApiDocker/.vs/TestApiDocker/v17/DocumentLayout.json Voir le fichier

@@ -0,0 +1,54 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\christophe_brachet\\Desktop\\TestApiDocker\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{9EA9D523-C331-4E33-8204-B4024392D267}|TestApiDocker\\TestApiDocker.csproj|c:\\users\\christophe_brachet\\desktop\\testapidocker\\testapidocker\\myunittest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{9EA9D523-C331-4E33-8204-B4024392D267}|TestApiDocker\\TestApiDocker.csproj|solutionrelative:testapidocker\\myunittest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{9EA9D523-C331-4E33-8204-B4024392D267}|TestApiDocker\\TestApiDocker.csproj|c:\\users\\christophe_brachet\\desktop\\testapidocker\\testapidocker\\models\\weatherforecast.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{9EA9D523-C331-4E33-8204-B4024392D267}|TestApiDocker\\TestApiDocker.csproj|solutionrelative:testapidocker\\models\\weatherforecast.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "WeatherForecast.cs",
"DocumentMoniker": "C:\\Users\\christophe_brachet\\Desktop\\TestApiDocker\\TestApiDocker\\Models\\WeatherForecast.cs",
"RelativeDocumentMoniker": "TestApiDocker\\Models\\WeatherForecast.cs",
"ToolTip": "C:\\Users\\christophe_brachet\\Desktop\\TestApiDocker\\TestApiDocker\\Models\\WeatherForecast.cs",
"RelativeToolTip": "TestApiDocker\\Models\\WeatherForecast.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAwAAAAkAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-08-26T21:34:59.064Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "MyUnitTest.cs",
"DocumentMoniker": "C:\\Users\\christophe_brachet\\Desktop\\TestApiDocker\\TestApiDocker\\MyUnitTest.cs",
"RelativeDocumentMoniker": "TestApiDocker\\MyUnitTest.cs",
"ToolTip": "C:\\Users\\christophe_brachet\\Desktop\\TestApiDocker\\TestApiDocker\\MyUnitTest.cs",
"RelativeToolTip": "TestApiDocker\\MyUnitTest.cs",
"ViewState": "AgIAAAkAAAAAAAAAAAAAAB4AAAALAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-08-26T21:21:10.154Z",
"EditorCaption": ""
}
]
}
]
}
]
}

BIN
TestApiDocker/.vs/TestApiDocker/v17/TestStore/0/000.testlog Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/v17/TestStore/0/testlog.manifest Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/v17/TestStore/1/000.testlog Voir le fichier


BIN
TestApiDocker/.vs/TestApiDocker/v17/TestStore/1/testlog.manifest Voir le fichier


+ 25
- 0
TestApiDocker/TestApiDocker.sln Voir le fichier

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35208.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApiDocker", "TestApiDocker\TestApiDocker.csproj", "{9EA9D523-C331-4E33-8204-B4024392D267}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9EA9D523-C331-4E33-8204-B4024392D267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EA9D523-C331-4E33-8204-B4024392D267}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EA9D523-C331-4E33-8204-B4024392D267}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EA9D523-C331-4E33-8204-B4024392D267}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {90F8E6B7-23C2-4D64-AA1A-21BA19F95C47}
EndGlobalSection
EndGlobal

+ 16
- 0
TestApiDocker/TestApiDocker/Models/WeatherForecast.cs Voir le fichier

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestApiDocker.Models
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }

}
}

+ 53
- 0
TestApiDocker/TestApiDocker/MyUnitTest.cs Voir le fichier

@@ -0,0 +1,53 @@
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Containers;
using DotNet.Testcontainers.Images;
using System.Net.Http.Json;
using TestApiDocker.Models;


namespace TestApiDocker
{
[TestClass]
public class MyUnitTest
{
private static readonly IContainer _container = new ContainerBuilder()
.WithImage("ecolocale/my-api:latest")
.WithPortBinding(9090, 9090)
.WithCleanUp(true)
.Build();

[TestInitialize]
public async Task StartContainer()
{
await _container.StartAsync();

}

[TestMethod]
public async Task ShouldReturnWeatherForecast()
{
//Laisser le temps de démarrer que le container se charge
await Task.Delay(1000);
HttpClient httpClient = new HttpClient();
Uri requestUri =
new UriBuilder(
Uri.UriSchemeHttp,
_container.Hostname,
_container.GetMappedPublicPort(9090),
"WeatherForecast"
).Uri;
List<WeatherForecast> weatherForecasts = await httpClient.GetFromJsonAsync<List<WeatherForecast>>(requestUri);
Assert.AreEqual(5, weatherForecasts.Count());

}

[TestCleanup]
public async Task DisposeContainer()
{
await _container.StopAsync();

}
}
}

+ 24
- 0
TestApiDocker/TestApiDocker/TestApiDocker.csproj Voir le fichier

@@ -0,0 +1,24 @@
<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.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="Testcontainers" Version="3.9.0" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>

BIN
docker-dotnetcore-api/.vs/docker-dotnetcore-api/DesignTimeBuild/.dtbcache.v2 Voir le fichier


BIN
docker-dotnetcore-api/.vs/docker-dotnetcore-api/FileContentIndex/85f069ee-3b06-4203-af6f-d66c82b9183c.vsidx Voir le fichier


+ 1016
- 0
docker-dotnetcore-api/.vs/docker-dotnetcore-api/config/applicationhost.config
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


BIN
docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/.futdcache.v2 Voir le fichier


BIN
docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/.suo Voir le fichier


BIN
docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/TestStore/0/000.testlog Voir le fichier


BIN
docker-dotnetcore-api/.vs/docker-dotnetcore-api/v17/TestStore/0/testlog.manifest Voir le fichier


+ 16
- 0
docker-dotnetcore-api/Dockerfile Voir le fichier

@@ -0,0 +1,16 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 9090
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["docker-dotnetcore-api.csproj", "."]
RUN dotnet restore "./docker-dotnetcore-api.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "docker-dotnetcore-api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "docker-dotnetcore-api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "docker-dotnetcore-api.dll"]

+ 44
- 0
docker-dotnetcore-api/Program.cs Voir le fichier

@@ -0,0 +1,44 @@
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://0.0.0.0:9090");
// Add services to the container.
// 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.UseSwagger();
app.UseSwaggerUI();

}

app.UseHttpsRedirection();

var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast")
.WithOpenApi();

app.Run();

record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}

+ 41
- 0
docker-dotnetcore-api/Properties/launchSettings.json Voir le fichier

@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40366",
"sslPort": 44378
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5281",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7047;http://localhost:5281",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

+ 8
- 0
docker-dotnetcore-api/appsettings.Development.json Voir le fichier

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

+ 9
- 0
docker-dotnetcore-api/appsettings.json Voir le fichier

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

+ 15
- 0
docker-dotnetcore-api/docker-dotnetcore-api.csproj Voir le fichier

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>docker_dotnetcore_api</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

</Project>

+ 6
- 0
docker-dotnetcore-api/docker-dotnetcore-api.csproj.user Voir le fichier

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
</PropertyGroup>
</Project>

+ 6
- 0
docker-dotnetcore-api/docker-dotnetcore-api.http Voir le fichier

@@ -0,0 +1,6 @@
@docker_dotnetcore_api_HostAddress = http://localhost:5281

GET {{docker_dotnetcore_api_HostAddress}}/weatherforecast/
Accept: application/json

###

Chargement…
Annuler
Enregistrer