diff --git a/src/Entities/ActivityEntity.cs b/src/Entities/ActivityEntity.cs index 351ef5a..d1af116 100644 --- a/src/Entities/ActivityEntity.cs +++ b/src/Entities/ActivityEntity.cs @@ -3,7 +3,7 @@ // PROJECT: Entities // SOLUTION: HeartTrack // DATE CREATED: 22/02/2024 -// AUTHOR: Antoine PEREDERII +// AUTHOR: HeartTeam //----------------------------------------------------------------------- using System.ComponentModel.DataAnnotations; diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index c5739f3..199d635 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -3,7 +3,7 @@ // PROJECT: Entities // SOLUTION: HeartTrack // DATE CREATED: 22/02/2024 -// AUTHOR: Antoine PEREDERII +// AUTHOR: HeartTeam //----------------------------------------------------------------------- using System.ComponentModel.DataAnnotations; diff --git a/src/Entities/DataSourceEntity.cs b/src/Entities/DataSourceEntity.cs index adef299..9a1eb1e 100644 --- a/src/Entities/DataSourceEntity.cs +++ b/src/Entities/DataSourceEntity.cs @@ -3,7 +3,7 @@ // PROJECT: Entities // SOLUTION: HeartTrack // DATE CREATED: 22/02/2024 -// AUTHOR: Antoine PEREDERII +// AUTHOR: HeartTeam //----------------------------------------------------------------------- using System.ComponentModel.DataAnnotations; diff --git a/src/Entities/HeartRateEntity.cs b/src/Entities/HeartRateEntity.cs index 5407cc1..bd3486d 100644 --- a/src/Entities/HeartRateEntity.cs +++ b/src/Entities/HeartRateEntity.cs @@ -3,7 +3,7 @@ // PROJECT: Entities // SOLUTION: HeartTrack // DATE CREATED: 22/02/2024 -// AUTHOR: Antoine PEREDERII +// AUTHOR: HeartTeam //----------------------------------------------------------------------- using System.ComponentModel.DataAnnotations; diff --git a/src/Entities/NotificationEntity.cs b/src/Entities/NotificationEntity.cs index 06650c2..c08204d 100644 --- a/src/Entities/NotificationEntity.cs +++ b/src/Entities/NotificationEntity.cs @@ -3,7 +3,7 @@ // PROJECT: Entities // SOLUTION: HeartTrack // DATE CREATED: 22/02/2024 -// AUTHOR: Antoine PEREDERII +// AUTHOR: HeartTeam //----------------------------------------------------------------------- using System.ComponentModel.DataAnnotations; diff --git a/src/Entities/StatisticEntity.cs b/src/Entities/StatisticEntity.cs index 7f00fb4..27e58ca 100644 --- a/src/Entities/StatisticEntity.cs +++ b/src/Entities/StatisticEntity.cs @@ -3,7 +3,7 @@ // PROJECT: Entities // SOLUTION: HeartTrack // DATE CREATED: 22/02/2024 -// AUTHOR: Antoine PEREDERII +// AUTHOR: HeartTeam //----------------------------------------------------------------------- using System.ComponentModel.DataAnnotations; diff --git a/src/Entities/TrainingEntity.cs b/src/Entities/TrainingEntity.cs index f0e01b2..f801790 100644 --- a/src/Entities/TrainingEntity.cs +++ b/src/Entities/TrainingEntity.cs @@ -3,7 +3,7 @@ // PROJECT: Entities // SOLUTION: HeartTrack // DATE CREATED: 22/02/2024 -// AUTHOR: Antoine PEREDERII +// AUTHOR: HeartTeam //----------------------------------------------------------------------- using System.ComponentModel.DataAnnotations; diff --git a/src/HeartTrack.sln b/src/HeartTrack.sln index 8947e4c..8bd8954 100644 --- a/src/HeartTrack.sln +++ b/src/HeartTrack.sln @@ -41,6 +41,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFMappers", "EFMappers\EFMa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APIMappers", "APIMappers\APIMappers.csproj", "{41D18203-1688-43BD-A3AC-FD0C2BD81909}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestsModel", "Tests\UnitTestsModel\UnitTestsModel.csproj", "{508D380F-145C-437E-A7DF-7A17C526B2F3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -115,6 +117,10 @@ Global {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Debug|Any CPU.Build.0 = Debug|Any CPU {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.ActiveCfg = Release|Any CPU {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.Build.0 = Release|Any CPU + {508D380F-145C-437E-A7DF-7A17C526B2F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {508D380F-145C-437E-A7DF-7A17C526B2F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {508D380F-145C-437E-A7DF-7A17C526B2F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {508D380F-145C-437E-A7DF-7A17C526B2F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -127,6 +133,7 @@ Global {E515C8B6-6282-4D8B-8523-7B3A13E4AF58} = {30FC2BE9-7397-445A-84AD-043CE70F4281} {31FA8E5E-D642-4C43-A2B2-02B9832B2CEC} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} {73EA27F2-9F0C-443F-A5EE-2960C983A422} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} + {508D380F-145C-437E-A7DF-7A17C526B2F3} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0F3487F4-66CA-4034-AC66-1BC899C9B523} diff --git a/src/HeartTrackAPI/Controllers/UsersController.cs b/src/HeartTrackAPI/Controllers/UsersController.cs index 709df3a..6780d6c 100644 --- a/src/HeartTrackAPI/Controllers/UsersController.cs +++ b/src/HeartTrackAPI/Controllers/UsersController.cs @@ -32,7 +32,7 @@ public class UsersController : Controller /// /// Récupère une page d'utilisateurs en fonction des critères de pagination et de tri fournis. /// - /// Les critères de pagination et de tri pour les utilisateurs. + /// Les critères de pagination et de tri pour les utilisateurs. Met None par defaut et/ou si le critère n'est pas correct /// Une page de données utilisateur selon les critères spécifiés. /// Retourne la page demandée d'utilisateurs. /// La demande de pagination est invalide. diff --git a/src/Shared/ActivityOrderCriteria.cs b/src/Shared/ActivityOrderCriteria.cs index 5c7b64a..3a5fc31 100644 --- a/src/Shared/ActivityOrderCriteria.cs +++ b/src/Shared/ActivityOrderCriteria.cs @@ -3,13 +3,20 @@ namespace Shared; public enum ActivityOrderCriteria { None, + ByIdActivity, ByType, ByDate, - ByDuration, - ByDistance, - ByElevation, - ByAverageSpeed, - ByAverageHeartRate, - ByCalories, - ByDescription + ByStartTime, + ByEndTime, + ByEffortFelt, + ByVariability, + ByVariance, + ByStandardDeviation, + ByAverage, + ByMaximum, + ByMinimum, + ByAverageTemperature, + ByHasAutoPause, + ByDataSourceId, + ByAthleteId } \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/ActivityTest.cs b/src/Tests/UnitTestsModel/ActivityTest.cs new file mode 100644 index 0000000..df8e2dd --- /dev/null +++ b/src/Tests/UnitTestsModel/ActivityTest.cs @@ -0,0 +1,166 @@ +//----------------------------------------------------------------------- +// FILENAME: ActivityTests.cs +// PROJECT: UnitTestsModel +// DATE CREATED: 16/03/2024 +// AUTHOR: HeartTeam +// PURPOSE: Contains unit tests for the Activity class in the Model namespace. +//----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using Model; +using Xunit; + +namespace UnitTestsModel +{ + /// + /// Contains unit tests for the class. + /// + public class ActivityTests + { + /// + /// Verifies that the constructor sets the effort property correctly when a valid effort is provided. + /// + [Fact] + public void Constructor_WithValidEffort_SetsEffort() + { + var date = DateTime.Now; + var validEffort = 3; + + var activity = new Activity( + id: 1, + type: "Running", + date: date, + startTime: date.AddHours(1), + endTime: date.AddHours(2), + effort: validEffort, + variability: 0.5f, + variance: 0.3f, + standardDeviation: 0.2f, + average: 150, + maximum: 180, + minimum: 120, + averageTemperature: 25.5f, + hasAutoPause: false, + user: new User(), + dataSource: new DataSource(1, "Type", "Model", 0.1f, new List(), new List()), + heartRates: null + ); + + Assert.Equal(validEffort, activity.Effort); + } + + /// + /// Verifies that the constructor throws an ArgumentException when an invalid effort is provided. + /// + [Fact] + public void Constructor_WithInvalidEffort_ThrowsArgumentException() + { + var date = DateTime.Now; + var invalidEffort = 6; + + Assert.Throws(() => new Activity( + id: 1, + type: "Running", + date: date, + startTime: date.AddHours(1), + endTime: date.AddHours(2), + effort: invalidEffort, + variability: 0.5f, + variance: 0.3f, + standardDeviation: 0.2f, + average: 150, + maximum: 180, + minimum: 120, + averageTemperature: 25.5f, + hasAutoPause: false, + user: new User(), + dataSource: new DataSource(1, "Type", "Model", 0.1f, new List(), new List()), + heartRates: null + )); + } + + /// + /// Verifies that the ToString method returns the expected string representation of the activity. + /// + [Fact] + public void ToString_ReturnsExpectedString() + { + var date = new DateTime(2023, 3, 16, 10, 0, 0); + var activity = new Activity( + id: 1, + type: "Running", + date: date, + startTime: date.AddHours(1), + endTime: date.AddHours(2), + effort: 3, + variability: 0.5f, + variance: 0.3f, + standardDeviation: 0.2f, + average: 150, + maximum: 180, + minimum: 120, + averageTemperature: 25.5f, + hasAutoPause: false, + user: new User(), + dataSource: new DataSource(1, "Type", "Model", 0.1f, new List(), new List()), + heartRates: null + ); + + var result = activity.ToString(); + + Assert.Contains("Activity #1: Running on 16/3/2023 from 11:00:00 to 12:00:00", result); + } + + /// + /// Verifies that the constructor sets all properties correctly. + /// + [Fact] + public void Constructor_SetsPropertiesCorrectly() + { + var date = DateTime.Now; + var user = new User(); + var dataSource = new DataSource(1, "Type", "Model", 0.1f, new List(), new List()); + var heartRates = new List(); + + var activity = new Activity( + id: 1, + type: "Running", + date: date, + startTime: date.AddHours(1), + endTime: date.AddHours(2), + effort: 3, + variability: 0.5f, + variance: 0.3f, + standardDeviation: 0.2f, + average: 150, + maximum: 180, + minimum: 120, + averageTemperature: 25.5f, + hasAutoPause: false, + user: user, + dataSource: dataSource, + heartRates: heartRates + ); + + Assert.Equal(1, activity.Id); + Assert.Equal("Running", activity.Type); + Assert.Equal(date, activity.Date); + Assert.Equal(date.AddHours(1), activity.StartTime); + Assert.Equal(date.AddHours(2), activity.EndTime); + Assert.Equal(3, activity.Effort); + Assert.Equal(0.5f, activity.Variability); + Assert.Equal(0.3f, activity.Variance); + Assert.Equal(0.2f, activity.StandardDeviation); + Assert.Equal(150, activity.Average); + Assert.Equal(180, activity.Maximum); + Assert.Equal(120, activity.Minimum); + Assert.Equal(25.5f, activity.AverageTemperature); + Assert.False(activity.HasAutoPause); + Assert.Equal(user, activity.Athlete); + Assert.Equal(dataSource, activity.DataSource); + Assert.Equal(heartRates, activity.HeartRates); + } + + } +} \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/AthleteTest.cs b/src/Tests/UnitTestsModel/AthleteTest.cs new file mode 100644 index 0000000..fdcac1b --- /dev/null +++ b/src/Tests/UnitTestsModel/AthleteTest.cs @@ -0,0 +1,35 @@ +using Model; +using Xunit; + +namespace Model.Tests +{ + public class AthleteTests + { + [Fact] + public void CheckAdd_ValidUser_ReturnsTrue() + { + // Arrange + var athlete = new Athlete(); + + // Act + var user = new User("hello13", "dkjd.png", "John", "Doe", "john@exemple.com", "password", "Male", 180.5f, 75.3f, new System.DateTime(1990, 5, 15), new Athlete()); + var result = athlete.CheckAdd(user); + + // Assert + Assert.True(result); + } + + [Fact] + public void CheckAdd_CoachUser_ReturnsFalse() + { + // Arrange + var athlete = new Athlete(); + + var user = new User("hello13", "dkjd.png", "John", "Doe", "john@exemple.com", "password", "Male", 180.5f, 75.3f, new System.DateTime(1990, 5, 15), new Coach()); + var result = athlete.CheckAdd(user); + + // Assert + Assert.False(result); + } + } +} \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/CoachTest.cs b/src/Tests/UnitTestsModel/CoachTest.cs new file mode 100644 index 0000000..57f8b5d --- /dev/null +++ b/src/Tests/UnitTestsModel/CoachTest.cs @@ -0,0 +1,36 @@ +using Model; +using Xunit; + +namespace Model.Tests +{ + public class CoachTests + { + [Fact] + public void CheckAdd_AthleteUser_ReturnsTrue() + { + // Arrange + var coach = new Coach(); + + // Act + var user = new User { Role = new Athlete() }; + var result = coach.CheckAdd(user); + + // Assert + Assert.True(result); + } + + [Fact] + public void CheckAdd_NonAthleteUser_ReturnsFalse() + { + // Arrange + var coach = new Coach(); + + // Act + var user = new User { Role = new Coach() }; + var result = coach.CheckAdd(user); + + // Assert + Assert.False(result); + } + } +} \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/DataSource.cs b/src/Tests/UnitTestsModel/DataSource.cs new file mode 100644 index 0000000..21cad2d --- /dev/null +++ b/src/Tests/UnitTestsModel/DataSource.cs @@ -0,0 +1,32 @@ +using Model; +using System.Collections.Generic; +using Xunit; + +namespace Model.Tests +{ + public class DataSourceTests + { + [Fact] + public void Constructor_WithArguments_InitializesProperties() + { + // Arrange + var id = 1; + var type = "Type"; + var model = "Model"; + var precision = 0.5f; + var athletes = new List(); + var activities = new List(); + + // Act + var dataSource = new DataSource(id, type, model, precision, athletes, activities); + + // Assert + Assert.Equal(id, dataSource.Id); + Assert.Equal(type, dataSource.Type); + Assert.Equal(model, dataSource.Model); + Assert.Equal(precision, dataSource.Precision); + Assert.Same(athletes, dataSource.Athletes); + Assert.Same(activities, dataSource.Activities); + } + } +} diff --git a/src/Tests/UnitTestsModel/GlobalUsings.cs b/src/Tests/UnitTestsModel/GlobalUsings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/src/Tests/UnitTestsModel/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/HeartRateTest.cs b/src/Tests/UnitTestsModel/HeartRateTest.cs new file mode 100644 index 0000000..bfdcae7 --- /dev/null +++ b/src/Tests/UnitTestsModel/HeartRateTest.cs @@ -0,0 +1,73 @@ +using Xunit; +using System; + +namespace Model.Tests +{ + public class HeartRateTests + { + [Fact] + public void HeartRate_Constructor_WithValidParameters() + { + // Arrange + int id = 1; + int bpm = 80; + TimeOnly timestamp = new TimeOnly(12, 30, 0); + Activity activity = new Activity(); + double? latitude = 40.7128; + double? longitude = -74.0060; + double? altitude = 10.5; + int? cadence = 120; + double? distance = 5.2; + double? speed = 10.5; + int? power = 200; + double? temperature = 25.5; + + // Act + var heartRate = new HeartRate(id, bpm, timestamp, activity, latitude, longitude, altitude, cadence, distance, speed, power, temperature); + + // Assert + Assert.Equal(id, heartRate.Id); + Assert.Equal(bpm, heartRate.Bpm); + Assert.Equal(timestamp, heartRate.Timestamp); + Assert.Equal(activity, heartRate.Activity); + Assert.Equal(latitude, heartRate.Latitude); + Assert.Equal(longitude, heartRate.Longitude); + Assert.Equal(altitude, heartRate.Altitude); + Assert.Equal(cadence, heartRate.Cadence); + Assert.Equal(distance, heartRate.Distance); + Assert.Equal(speed, heartRate.Speed); + Assert.Equal(power, heartRate.Power); + Assert.Equal(temperature, heartRate.Temperature); + } + + [Fact] + public void HeartRate_ToString_ReturnsExpectedString() + { + // Arrange + int id = 1; + int bpm = 80; + TimeOnly timestamp = new TimeOnly(12, 30, 0); + Activity activity = new Activity(); + double? latitude = 40.7128; + double? longitude = -74.0060; + double? altitude = 10.5; + int? cadence = 120; + double? distance = 5.2; + double? speed = 10.5; + int? power = 200; + double? temperature = 25.5; + var heartRate = new HeartRate(id, bpm, timestamp, activity, latitude, longitude, altitude, cadence, distance, speed, power, temperature); + + // Act + var result = heartRate.ToString(); + + // Assert + Assert.Contains($"HeartRate #{id}", result); + Assert.Contains($"{bpm} bpm", result); + Assert.Contains($"{timestamp:HH:mm:ss}", result); + Assert.Contains($"temperature of {temperature}°C", result); + Assert.Contains($"altitude of {altitude}m", result); + Assert.Contains($"at {longitude}°E and {latitude}°N", result); + } + } +} \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/LargeImageTest.cs b/src/Tests/UnitTestsModel/LargeImageTest.cs new file mode 100644 index 0000000..d1f5552 --- /dev/null +++ b/src/Tests/UnitTestsModel/LargeImageTest.cs @@ -0,0 +1,38 @@ +using Xunit; + +namespace Model.Tests +{ + public class LargeImageTests + { + [Fact] + public void Equals_ReturnsTrue_WhenBase64StringsAreEqual() + { + // Arrange + var base64String = "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHN0cmluZw=="; + var image1 = new LargeImage(base64String); + var image2 = new LargeImage(base64String); + + // Act + var result = image1.Equals(image2); + + // Assert + Assert.True(result); + } + + [Fact] + public void Equals_ReturnsFalse_WhenBase64StringsAreDifferent() + { + // Arrange + var base64String1 = "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHN0cmluZw=="; + var base64String2 = "VGhpcyBpcyBhIGJhc2U2NSBlbmNvZGVkIHN0cmluZw=="; + var image1 = new LargeImage(base64String1); + var image2 = new LargeImage(base64String2); + + // Act + var result = image1.Equals(image2); + + // Assert + Assert.False(result); + } + } +} \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/NotificationTest.cs b/src/Tests/UnitTestsModel/NotificationTest.cs new file mode 100644 index 0000000..fc9fbd1 --- /dev/null +++ b/src/Tests/UnitTestsModel/NotificationTest.cs @@ -0,0 +1,30 @@ +using Xunit; + +namespace Model.Tests +{ + public class NotificationTests + { + [Fact] + public void Constructor_InitializesPropertiesCorrectly() + { + // Arrange + int id = 1; + string message = "Test notification"; + DateTime date = DateTime.Now; + bool status = false; + string urgency = "High"; + int toUserId = 10; + + // Act + var notification = new Notification(id, message, date, status, urgency, toUserId); + + // Assert + Assert.Equal(id, notification.IdNotif); + Assert.Equal(message, notification.Message); + Assert.Equal(date, notification.Date); + Assert.Equal(status, notification.Statut); + Assert.Equal(urgency, notification.Urgence); + Assert.Equal(toUserId, notification.ToUserId); + } + } +} \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/RelationshipTest.cs b/src/Tests/UnitTestsModel/RelationshipTest.cs new file mode 100644 index 0000000..5d69495 --- /dev/null +++ b/src/Tests/UnitTestsModel/RelationshipTest.cs @@ -0,0 +1,29 @@ +using Xunit; + +namespace Model.Tests +{ + public class RelationshipRequestTests + { + [Fact] + public void Constructor_InitializesPropertiesCorrectly() + { + // Arrange + int id = 1; + int fromUserId = 2; + int toUserId = 3; + + // Act + var request = new RelationshipRequest + { + Id = id, + FromUser = fromUserId, + ToUser = toUserId + }; + + // Assert + Assert.Equal(id, request.Id); + Assert.Equal(fromUserId, request.FromUser); + Assert.Equal(toUserId, request.ToUser); + } + } +} \ No newline at end of file diff --git a/src/Tests/UnitTestsModel/RoleTest.cs b/src/Tests/UnitTestsModel/RoleTest.cs new file mode 100644 index 0000000..5769808 --- /dev/null +++ b/src/Tests/UnitTestsModel/RoleTest.cs @@ -0,0 +1,36 @@ +using Xunit; + +namespace Model.Tests +{ + public class RoleTests + { + [Fact] + public void AddUser_WithValidUser_ReturnsTrue() + { + // Arrange + var role = new Athlete(); // Vous pouvez utiliser Athlete ou Coach selon votre besoin + var user = new User("hello13", "dkjd.png", "John", "Doe", "john@exemple.com", "password", "M", 180.5f, 75.3f, new System.DateTime(1990, 5, 15), new Athlete()); + + // Act + bool result = role.AddUser(user); + + // Assert + Assert.True(result); + } + + [Fact] + public void AddUser_WithInvalidUser_ReturnsFalse() + { + // Arrange + var role = new Athlete(); // Vous pouvez utiliser Athlete ou Coach selon votre besoin + var user = new User(); // Créez un objet User invalide + + // Act + bool result = role.AddUser(user); + + // Assert + Assert.False(result); + } + + } +} diff --git a/src/UnitTestsEntities2/UnitTestsEntities2.csproj b/src/Tests/UnitTestsModel/UnitTestsModel.csproj similarity index 51% rename from src/UnitTestsEntities2/UnitTestsEntities2.csproj rename to src/Tests/UnitTestsModel/UnitTestsModel.csproj index 9c5b30a..6e23191 100644 --- a/src/UnitTestsEntities2/UnitTestsEntities2.csproj +++ b/src/Tests/UnitTestsModel/UnitTestsModel.csproj @@ -1,23 +1,29 @@ - - - - net8.0 - enable - enable - - false - true - - + + + + net8.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + - - - - - - - - - - - + + + + diff --git a/src/Tests/UnitTestsModel/UserTest.cs b/src/Tests/UnitTestsModel/UserTest.cs new file mode 100644 index 0000000..efd95a8 --- /dev/null +++ b/src/Tests/UnitTestsModel/UserTest.cs @@ -0,0 +1,41 @@ +using Xunit; + +namespace Model.Tests +{ + public class UserTests + { + [Fact] + public void UserConstructor_ValidParameters_ConstructsObject() + { + // Arrange + string username = "john_doe"; + string profilePicture = "profile.jpg"; + string lastName = "Doe"; + string firstName = "John"; + string email = "john.doe@example.com"; + string password = "password"; + string sex = "Male"; + float length = 180.5f; + float weight = 75.3f; + DateTime dateOfBirth = new DateTime(1990, 5, 15); + Role role = new Athlete(); // You can change this to the appropriate role + + // Act + User user = new User(username, profilePicture, lastName, firstName, email, password, sex, length, weight, dateOfBirth, role); + + // Assert + Assert.NotNull(user); + Assert.Equal(username, user.Username); + Assert.Equal(profilePicture, user.ProfilePicture); + Assert.Equal(lastName, user.LastName); + Assert.Equal(firstName, user.FirstName); + Assert.Equal(email, user.Email); + Assert.Equal(password, user.MotDePasse); + Assert.Equal(sex, user.Sexe); + Assert.Equal(length, user.Lenght); + Assert.Equal(weight, user.Weight); + Assert.Equal(dateOfBirth, user.DateOfBirth); + Assert.Equal(role, user.Role); + } + } +} \ No newline at end of file diff --git a/src/UnitTestsEntities2/UnitTest1.cs b/src/UnitTestsEntities2/UnitTest1.cs deleted file mode 100644 index 8b121a7..0000000 --- a/src/UnitTestsEntities2/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace UnitTestsEntities2 -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} \ No newline at end of file