commit
62387e36f5
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\APILOL\APILOL.csproj" />
|
||||||
|
<ProjectReference Include="..\StubLib\StubLib.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,62 @@
|
|||||||
|
using APILOL.Controllers;
|
||||||
|
using APILOL.Mapper;
|
||||||
|
using DTO;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using StubLib;
|
||||||
|
|
||||||
|
namespace TestUnitaire
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class UnitTestChampion
|
||||||
|
{
|
||||||
|
private readonly ChampionsController controller;
|
||||||
|
private readonly StubData stub;
|
||||||
|
public UnitTestChampion()
|
||||||
|
{
|
||||||
|
stub = new StubData();
|
||||||
|
controller = new ChampionsController();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task TestGet()
|
||||||
|
{
|
||||||
|
var champions = await controller.Get();
|
||||||
|
|
||||||
|
var resultObject = champions as OkObjectResult;
|
||||||
|
Assert.IsNotNull(resultObject);
|
||||||
|
|
||||||
|
var resultType = resultObject?.Value as IEnumerable<ChampionDTO>;
|
||||||
|
Assert.IsNotNull(resultType);
|
||||||
|
|
||||||
|
Assert.AreEqual(resultType.Count(), await stub.ChampionsMgr.GetNbItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task TestPost()
|
||||||
|
{
|
||||||
|
var ChampionDtoToTest = new ChampionDTO { Bio= "This champion is a legendary Fox", Name="Foxane"};
|
||||||
|
|
||||||
|
var champions = await controller.Post(ChampionDtoToTest);
|
||||||
|
var resultObject = champions as OkObjectResult;
|
||||||
|
Assert.IsNotNull(resultObject);
|
||||||
|
|
||||||
|
var resultType = resultObject?.Value as IEnumerable<ChampionDTO>;
|
||||||
|
Assert.IsNotNull(resultType);
|
||||||
|
|
||||||
|
Assert.AreEqual(resultType.Last(), stub.ChampionsMgr.GetItems(-1, await stub.ChampionsMgr.GetNbItems()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestPut()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestDelete()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|
Loading…
Reference in new issue