From 9cddc063436a86c4679c0befa8c46730dabacd2c Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 28 Mar 2024 04:48:09 +0100 Subject: [PATCH] minor update (sexe string to char) --- src/Dto/AthleteDto.cs | 2 +- src/Dto/Auth/RegisterRequestDto.cs | 2 +- src/Dto/ResponseUserDto.cs | 2 +- src/Dto/Tiny/UserTinyDto.cs | 2 +- src/Entities/AthleteEntity.cs | 2 +- src/Model/User.cs | 4 ++-- src/StubAPI/AthleteService.cs | 6 +++--- src/StubbedContextLib/AthleteStubbedContext.cs | 10 +++++----- src/Tests/ConsoleTestEntities/Program.cs | 4 ++-- .../Controllers/UsersControllerTest.cs | 6 +++--- .../UnitTestsEntities/AthleteEntityTests.cs | 12 ++++++------ .../UnitTestsEntities/FriendshipEntityTests.cs | 14 +++++++------- .../UnitTestsEntities/NotificationEntityTests.cs | 8 ++++---- .../UnitTestsEntities/StatisticEntityTests.cs | 8 ++++---- .../UnitTestsEntities/TrainingEntityTests.cs | 16 ++++++++-------- src/Tests/UnitTestsModel/AthleteTest.cs | 4 ++-- src/Tests/UnitTestsModel/RoleTest.cs | 2 +- src/Tests/UnitTestsModel/UserTest.cs | 2 +- 18 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/Dto/AthleteDto.cs b/src/Dto/AthleteDto.cs index d5c94c0..be49bf5 100644 --- a/src/Dto/AthleteDto.cs +++ b/src/Dto/AthleteDto.cs @@ -12,7 +12,7 @@ public class UserDto [MaxLength(100)] public required string FirstName { get; set; } public required string Email { get; set; } - public required string Sexe { get; set; } + public required char Sexe { get; set; } public float Lenght { get; set; } public float Weight { get; set; } public string? Password { get; set; } diff --git a/src/Dto/Auth/RegisterRequestDto.cs b/src/Dto/Auth/RegisterRequestDto.cs index ccd837e..c6af1ab 100644 --- a/src/Dto/Auth/RegisterRequestDto.cs +++ b/src/Dto/Auth/RegisterRequestDto.cs @@ -18,7 +18,7 @@ public class RegisterRequestDto [EmailAddress] public string Email { get; set; } [Required(ErrorMessage = "Sexe is required")] - public string Sexe { get; set; } + public char Sexe { get; set; } [Required(ErrorMessage = "Size is required")] public float Size { get; set; } [Required(ErrorMessage = "Weight is required")] diff --git a/src/Dto/ResponseUserDto.cs b/src/Dto/ResponseUserDto.cs index 673d00f..79285f6 100644 --- a/src/Dto/ResponseUserDto.cs +++ b/src/Dto/ResponseUserDto.cs @@ -13,7 +13,7 @@ public class ResponseUserDto [MaxLength(100)] public required string FirstName { get; set; } public required string Email { get; set; } - public required string Sexe { get; set; } + public required char Sexe { get; set; } public float Lenght { get; set; } public float Weight { get; set; } public string? Password { get; set; } diff --git a/src/Dto/Tiny/UserTinyDto.cs b/src/Dto/Tiny/UserTinyDto.cs index 7f5df8f..6ca667f 100644 --- a/src/Dto/Tiny/UserTinyDto.cs +++ b/src/Dto/Tiny/UserTinyDto.cs @@ -12,7 +12,7 @@ public class UserTinyDto [MaxLength(100)] public required string FirstName { get; set; } public required string Email { get; set; } - public required string Sexe { get; set; } + public required char Sexe { get; set; } public float Lenght { get; set; } public float Weight { get; set; } public string? Password { get; set; } diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index 7d1977d..a661ea8 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -59,7 +59,7 @@ namespace Entities /// [MaxLength(1)] [Required(ErrorMessage = "Athlete Sexe is ")] - public string Sexe { get; set; } + public char Sexe { get; set; } /// /// Gets or sets the height of the athlete. diff --git a/src/Model/User.cs b/src/Model/User.cs index 3a8acd6..ccccf3f 100644 --- a/src/Model/User.cs +++ b/src/Model/User.cs @@ -9,7 +9,7 @@ public class User public string FirstName { get; set; } public string Email { get; set; } public string? MotDePasse { get; set; } - public string Sexe { get; set; } + public char Sexe { get; set; } public float Lenght { get; set; } public float Weight { get; set; } public DateTime DateOfBirth { get; set; } @@ -22,7 +22,7 @@ public class User public List Users { get; set; } = new List(); public List DataSources { get; set; } = new List(); - public User( string username, string profilePicture, string nom, string prenom, string email, string motDePasse, string sexe, float taille, float poids, DateTime dateNaissance, Role role) + public User( string username, string profilePicture, string nom, string prenom, string email, string motDePasse, char sexe, float taille, float poids, DateTime dateNaissance, Role role) { Username = username; ProfilePicture = profilePicture; diff --git a/src/StubAPI/AthleteService.cs b/src/StubAPI/AthleteService.cs index d51a7c7..43673e2 100644 --- a/src/StubAPI/AthleteService.cs +++ b/src/StubAPI/AthleteService.cs @@ -13,21 +13,21 @@ public class UserService : IUserRepository new User { Id = 1, Username = "DoeDoe", ProfilePicture = "https://images.unsplash.com/photo-1682687982134-2ac563b2228b?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", FirstName = "John", LastName = "Doe", - Sexe = "M", Lenght = 180, Weight = 70, DateOfBirth = new DateTime(1990, 1, 1), + Sexe = 'M', Lenght = 180, Weight = 70, DateOfBirth = new DateTime(1990, 1, 1), Email = "john.doe@example.com", Role = new Athlete() }, new User { Id = 2, Username = "SmithSmith", ProfilePicture = "https://images.unsplash.com/photo-1709507779917-242b560288be?q=80&w=2080&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", FirstName = "Jane", LastName = "Smith", - Sexe = "F", Lenght = 170, Weight = 60, DateOfBirth = new DateTime(1992, 2, 2), + Sexe = 'F', Lenght = 170, Weight = 60, DateOfBirth = new DateTime(1992, 2, 2), Email = "athlete2@example.com", Role = new Coach() }, new User { Id = 3, Username = "Athlete3", ProfilePicture = "https://plus.unsplash.com/premium_photo-1705091981693-6006f8a20479?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", FirstName = "First3", LastName = "Last3", - Sexe = "M", Lenght = 190, Weight = 80, DateOfBirth = new DateTime(1994, 3, 3), Email = "ath@ex.fr", + Sexe = 'M', Lenght = 190, Weight = 80, DateOfBirth = new DateTime(1994, 3, 3), Email = "ath@ex.fr", Role = new Athlete() } diff --git a/src/StubbedContextLib/AthleteStubbedContext.cs b/src/StubbedContextLib/AthleteStubbedContext.cs index b87b4b4..2644757 100644 --- a/src/StubbedContextLib/AthleteStubbedContext.cs +++ b/src/StubbedContextLib/AthleteStubbedContext.cs @@ -42,11 +42,11 @@ namespace StubbedContextLib modelBuilder.Entity().HasData(picture); modelBuilder.Entity().HasData( - new AthleteEntity { Id = 1, UserName = "Doe",ProfilPicture = picture2, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") ,LastName = "Doe", FirstName = "John", Email = "john.doe@example.com", PasswordHash = "password123", Sexe = "M", Length = 1.80, Weight = 75, DateOfBirth = new DateOnly(1990, 01, 01), IsCoach = true , DataSourceId = 1}, - new AthleteEntity { Id = 2, UserName = "Smith",ProfilPicture = picture2,LastName = "Smith", FirstName = "Jane", Email = "jane.smith@exemple.com", PasswordHash = "secure456", Sexe = "F", Length = 1.65, Weight = 60, DateOfBirth = new DateOnly(1995, 01, 01), IsCoach = false, DataSourceId = 1 }, - new AthleteEntity { Id = 3, UserName = "Martin",ProfilPicture = picture2,ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") ,LastName = "Martin", FirstName = "Paul", Email = "paul.martin@example.com", PasswordHash = "super789", Sexe = "M", Length = 1.75, Weight = 68, DateOfBirth = new DateOnly(1992, 01, 01), IsCoach = true, DataSourceId = 1}, - new AthleteEntity { Id = 4, UserName = "Brown",ProfilPicture = picture2, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"),LastName = "Brown", FirstName = "Anna", Email = "anna.brown@example.com", PasswordHash = "test000", Sexe = "F", Length = 1.70, Weight = 58, DateOfBirth = new DateOnly(1993, 01, 01), IsCoach = false, DataSourceId = 2 }, - new AthleteEntity { Id = 5, UserName = "Lee", ProfilPicture = picture2, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"),LastName = "Lee", FirstName = "Bruce", Email = "bruce.lee@example.com", PasswordHash = "hello321", Sexe = "M", Length = 2.0, Weight = 90, DateOfBirth = new DateOnly(1991, 01, 01), IsCoach = false, DataSourceId = 3 } + new AthleteEntity { Id = 1, UserName = "Doe",ProfilPicture = picture2, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") ,LastName = "Doe", FirstName = "John", Email = "john.doe@example.com", PasswordHash = "password123", Sexe = 'M', Length = 1.80, Weight = 75, DateOfBirth = new DateOnly(1990, 01, 01), IsCoach = true , DataSourceId = 1}, + new AthleteEntity { Id = 2, UserName = "Smith",ProfilPicture = picture2,LastName = "Smith", FirstName = "Jane", Email = "jane.smith@exemple.com", PasswordHash = "secure456", Sexe = 'F', Length = 1.65, Weight = 60, DateOfBirth = new DateOnly(1995, 01, 01), IsCoach = false, DataSourceId = 1 }, + new AthleteEntity { Id = 3, UserName = "Martin",ProfilPicture = picture2,ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") ,LastName = "Martin", FirstName = "Paul", Email = "paul.martin@example.com", PasswordHash = "super789", Sexe = 'M', Length = 1.75, Weight = 68, DateOfBirth = new DateOnly(1992, 01, 01), IsCoach = true, DataSourceId = 1}, + new AthleteEntity { Id = 4, UserName = "Brown",ProfilPicture = picture2, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"),LastName = "Brown", FirstName = "Anna", Email = "anna.brown@example.com", PasswordHash = "test000", Sexe = 'F', Length = 1.70, Weight = 58, DateOfBirth = new DateOnly(1993, 01, 01), IsCoach = false, DataSourceId = 2 }, + new AthleteEntity { Id = 5, UserName = "Lee", ProfilPicture = picture2, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"),LastName = "Lee", FirstName = "Bruce", Email = "bruce.lee@example.com", PasswordHash = "hello321", Sexe = 'M', Length = 2.0, Weight = 90, DateOfBirth = new DateOnly(1991, 01, 01), IsCoach = false, DataSourceId = 3 } ); } } diff --git a/src/Tests/ConsoleTestEntities/Program.cs b/src/Tests/ConsoleTestEntities/Program.cs index 44bc88b..12ac022 100644 --- a/src/Tests/ConsoleTestEntities/Program.cs +++ b/src/Tests/ConsoleTestEntities/Program.cs @@ -81,7 +81,7 @@ class Program Console.WriteLine("Accès à l'athlete de sexe 'F' :"); Console.WriteLine("---------------------------------"); - foreach (var athlete in db.AthletesSet.Where(a => a.Sexe == "F")) + foreach (var athlete in db.AthletesSet.Where(a => a.Sexe == 'F')) { Console.WriteLine($"\t{athlete.Id} - {athlete.UserName}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } @@ -755,7 +755,7 @@ class Program Console.WriteLine("Test d'ajout, de modification et de suppression des athletes :"); var picture = "https://davidalmeida.site/assets/me_avatar.f77af006.png"; // Ajout d'un nouveau livre - var newAthlete = new AthleteEntity { UserName = "Doe", LastName = "Doe",ProfilPicture = picture,FirstName = "John", Email = "essaie.example.com", PasswordHash = "TheNewPassword", Sexe = "M", Length = 1.80, Weight = 90, DateOfBirth = new DateOnly(2024, 02, 22), IsCoach = false }; + var newAthlete = new AthleteEntity { UserName = "Doe", LastName = "Doe",ProfilPicture = picture,FirstName = "John", Email = "essaie.example.com", PasswordHash = "TheNewPassword", Sexe = 'M', Length = 1.80, Weight = 90, DateOfBirth = new DateOnly(2024, 02, 22), IsCoach = false }; db.AthletesSet.Add(newAthlete); db.SaveChanges(); diff --git a/src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs b/src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs index 3a9ce3a..5896ea3 100644 --- a/src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs +++ b/src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs @@ -32,7 +32,7 @@ public class UsersControllerTest ProfilePicture = "https://images.unsplash.com/photo-1682687982134-2ac563b2228b?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", FirstName = "John", LastName = "Doe", - Sexe = "M", Lenght = 180, Weight = 70, DateOfBirth = new DateTime(1990, 1, 1), + Sexe = 'M', Lenght = 180, Weight = 70, DateOfBirth = new DateTime(1990, 1, 1), Email = "john.doe@example.com", Role = new Athlete() }, @@ -42,7 +42,7 @@ public class UsersControllerTest ProfilePicture = "https://images.unsplash.com/photo-1709507779917-242b560288be?q=80&w=2080&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", FirstName = "Jane", LastName = "Smith", - Sexe = "F", Lenght = 170, Weight = 60, DateOfBirth = new DateTime(1992, 2, 2), + Sexe = 'F', Lenght = 170, Weight = 60, DateOfBirth = new DateTime(1992, 2, 2), Email = "athlete2@example.com", Role = new Coach() }, @@ -52,7 +52,7 @@ public class UsersControllerTest ProfilePicture = "https://plus.unsplash.com/premium_photo-1705091981693-6006f8a20479?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", FirstName = "First3", LastName = "Last3", - Sexe = "M", Lenght = 190, Weight = 80, DateOfBirth = new DateTime(1994, 3, 3), Email = "ath@ex.fr", + Sexe = 'M', Lenght = 190, Weight = 80, DateOfBirth = new DateTime(1994, 3, 3), Email = "ath@ex.fr", Role = new Athlete() } ]; diff --git a/src/Tests/UnitTestsEntities/AthleteEntityTests.cs b/src/Tests/UnitTestsEntities/AthleteEntityTests.cs index 2bced05..81a6d6b 100644 --- a/src/Tests/UnitTestsEntities/AthleteEntityTests.cs +++ b/src/Tests/UnitTestsEntities/AthleteEntityTests.cs @@ -16,7 +16,7 @@ public class AthleteEntityTests (DatabaseFixture fixture) : IClassFixture