Documentation_UT_Client #1
Documentation_UT_Client
into master
2 years ago
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 97 KiB |
@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ApiLol\ApiLol.csproj" />
|
||||||
|
<ProjectReference Include="..\DTO\DTO.csproj" />
|
||||||
|
</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 DTO;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Model;
|
||||||
|
using StubLib;
|
||||||
|
|
||||||
|
namespace ApiTests
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class ChampionsControllerTest
|
||||||
|
{
|
||||||
|
private readonly StubData stub;
|
||||||
|
private readonly ChampionsController champs;
|
||||||
|
public ChampionsControllerTest()
|
||||||
|
{
|
||||||
|
stub = new StubData();
|
||||||
|
champs = new ChampionsController(stub);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task TestGetChampions()
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var champion = await champs.Get();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
var objectResult = champion as OkObjectResult;
|
||||||
|
Assert.IsNotNull(objectResult);
|
||||||
|
|
||||||
|
var champions = objectResult?.Value as IEnumerable<ChampionDto>;
|
||||||
|
Assert.IsNotNull(champions);
|
||||||
|
|
||||||
|
Assert.AreEqual(champions.Count(), await stub.ChampionsMgr.GetNbItems());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task TestPostChampion()
|
||||||
|
{
|
||||||
|
//Arange
|
||||||
|
var ChampionDto = new ChampionDto
|
||||||
|
{
|
||||||
|
Name = "Sylas",
|
||||||
|
Bio = "Good"
|
||||||
|
};
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var championsResult = await champs.Post(ChampionDto);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
var objectResult = championsResult as CreatedAtActionResult;
|
||||||
|
Assert.IsNotNull(objectResult);
|
||||||
|
|
||||||
|
var champions = objectResult?.Value as Champion;
|
||||||
|
Assert.IsNotNull(champions);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|