diff --git a/Sources/BowlingApi/Controllers/PartieController.cs b/Sources/BowlingApi/Controllers/PartieController.cs index f8fbe59..64df73d 100644 --- a/Sources/BowlingApi/Controllers/PartieController.cs +++ b/Sources/BowlingApi/Controllers/PartieController.cs @@ -7,6 +7,7 @@ using BowlingEF.Entities; using BowlingLib.Model; using BowlingService; using BowlingService.Interfaces; +using DTOs; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -162,7 +163,15 @@ namespace BowlingApi.Controllers } + public Task Put(int? score, PartieDTO partie) + { + throw new NotImplementedException(); + } + public Task Put(long id, PartieDTO parti) + { + throw new NotImplementedException(); + } } } diff --git a/Sources/DTOs/PartieDTO.cs b/Sources/DTOs/PartieDTO.cs index 62334dd..b42e18b 100644 --- a/Sources/DTOs/PartieDTO.cs +++ b/Sources/DTOs/PartieDTO.cs @@ -15,7 +15,8 @@ namespace DTOs public class PartieDTO { #region Properties - + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } public JoueurDTO Joueur { get; set; } diff --git a/Sources/Tests/BowlingAPITest/TestPartiControlleur.cs b/Sources/Tests/BowlingAPITest/TestPartiControlleur.cs index ff24615..3ed718f 100644 --- a/Sources/Tests/BowlingAPITest/TestPartiControlleur.cs +++ b/Sources/Tests/BowlingAPITest/TestPartiControlleur.cs @@ -92,6 +92,25 @@ namespace BowlingAPITest [Fact] public async Task Put_With_Valid_parti_Should_Return_Ok_With_parti() + [Fact] + public async Task Put_With_Invalid_Joueur_Should_Return_BadRequest() + { + // Arrange + var joueurController = new JoueurController(null); + + // Act + var result = await joueurController.Put(null, null); + + // Assert + result.Should().BeOfType>(); + var actionResult = result as ActionResult; + actionResult.Result.Should().BeOfType(); + var badRequestResult = actionResult.Result as BadRequestObjectResult; + badRequestResult.Value.Should().Be("Le joueur est obligatoire"); + } + + [Fact] + public async Task Put_With_Valid_parti_Should_Return_Ok_With_Joueur() { // Arrange var parti = new PartieDTO { Id = 1, Score = 1 }; @@ -184,6 +203,24 @@ namespace BowlingAPITest + [Fact] + public async Task Post_With_Invalid_Joueur_Should_Return_BadRequest() + { + // Arrange + var joueurController = new JoueurController(null); + + // Act + var result = await joueurController.Post(null); + + // Assert + result.Should().BeOfType>(); + var actionResult = result as ActionResult; + actionResult.Result.Should().BeOfType(); + var badRequestResult = actionResult.Result as BadRequestObjectResult; + badRequestResult.Value.Should().Be("La partie est obligatoire"); + } + + }