Mise en place d'entités #4
Merged
AlexandreRuiz
merged 17 commits from task/tu
into develop
3 years ago
@ -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.3.0" /> |
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> |
||||
<PackageReference Include="xunit" Version="2.4.1" /> |
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> |
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
<PrivateAssets>all</PrivateAssets> |
||||
</PackageReference> |
||||
<PackageReference Include="coverlet.collector" Version="3.1.0"> |
||||
<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> |
@ -1,17 +1,16 @@ |
||||
namespace espacecollab.backend.api |
||||
namespace espacecollab.backend.api; |
||||
|
||||
public static class Program |
||||
{ |
||||
public static class Program |
||||
public static void Main(string[] args) |
||||
{ |
||||
public static void Main(string[] args) |
||||
{ |
||||
CreateHostBuilder(args).Build().Run(); |
||||
} |
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => |
||||
Host.CreateDefaultBuilder(args) |
||||
.ConfigureWebHostDefaults(webBuilder => |
||||
{ |
||||
webBuilder.UseStartup<Startup>(); |
||||
}); |
||||
CreateHostBuilder(args).Build().Run(); |
||||
} |
||||
} |
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => |
||||
Host.CreateDefaultBuilder(args) |
||||
.ConfigureWebHostDefaults(webBuilder => |
||||
{ |
||||
webBuilder.UseStartup<Startup>(); |
||||
}); |
||||
} |
Loading…
Reference in new issue