From f9053b73e37492707e6712fae661095d83c614b5 Mon Sep 17 00:00:00 2001 From: anperederi Date: Fri, 23 Feb 2024 08:29:53 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20somes=20console=20tests=20for?= =?UTF-8?q?=20Entities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DbContextLib/LibraryContext.cs | 100 +++- src/Entities/ActivityEntity.cs | 123 ++++- src/Entities/AthleteEntity.cs | 112 +++- src/Entities/DataSourceEntity.cs | 53 +- src/Entities/HeartRateEntity.cs | 69 ++- src/Entities/NotificationEntity.cs | 63 ++- src/Entities/StatisticEntity.cs | 63 ++- src/Entities/TrainingEntity.cs | 69 ++- .../ActivityStubbedContext.cs | 64 ++- .../AthleteStubbedContext.cs | 61 ++- .../DataSourceStubbedContext.cs | 59 ++- .../HeartRateStubbedContext.cs | 59 ++- ...> 20240222104952_MyMigrations.Designer.cs} | 26 +- ...ions.cs => 20240222104952_MyMigrations.cs} | 8 +- .../TrainingStubbedContextModelSnapshot.cs | 24 +- .../NotificationStubbedContext.cs | 59 ++- .../StatisticStubbedContext.cs | 59 ++- .../TrainingStubbedContext.cs | 59 ++- src/Tests/ConsoleTestEntities/Program.cs | 497 ++++++++++++++++-- .../ConsoleTestEntities/uca.HeartTrack.db | Bin 45056 -> 45056 bytes 20 files changed, 1243 insertions(+), 384 deletions(-) rename src/StubbedContextLib/Migrations/{20240222102358_MyMigrations.Designer.cs => 20240222104952_MyMigrations.Designer.cs} (97%) rename src/StubbedContextLib/Migrations/{20240222102358_MyMigrations.cs => 20240222104952_MyMigrations.cs} (97%) diff --git a/src/DbContextLib/LibraryContext.cs b/src/DbContextLib/LibraryContext.cs index 33b2fea..2a41084 100644 --- a/src/DbContextLib/LibraryContext.cs +++ b/src/DbContextLib/LibraryContext.cs @@ -1,38 +1,86 @@ -using Entities; -using Microsoft.EntityFrameworkCore; +//----------------------------------------------------------------------- +// FILENAME: LibraryContext.cs +// PROJECT: DbContextLib +// SOLUTION: FitnessApp +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- -namespace DbContextLib; +using Entities; +using Microsoft.EntityFrameworkCore; -public class LibraryContext : DbContext +namespace DbContextLib { - public DbSet AthletesSet { get; set; } + /// + /// Represents the database context for the FitnessApp. + /// + public class LibraryContext : DbContext + { + /// + /// Gets or sets the set of athletes. + /// + public DbSet AthletesSet { get; set; } - public DbSet ActivitiesSet { get; set; } + /// + /// Gets or sets the set of activities. + /// + public DbSet ActivitiesSet { get; set; } - public DbSet DataSourcesSet { get; set; } - public DbSet HeartRatesSet { get; set; } - public DbSet NotificationsSet { get; set; } - public DbSet StatisticsSet { get; set; } - public DbSet TrainingsSet { get; set; } + /// + /// Gets or sets the set of data sources. + /// + public DbSet DataSourcesSet { get; set; } - public LibraryContext() - :base() - { } + /// + /// Gets or sets the set of heart rates. + /// + public DbSet HeartRatesSet { get; set; } - public LibraryContext(DbContextOptions options) - :base(options) - { } + /// + /// Gets or sets the set of notifications. + /// + public DbSet NotificationsSet { get; set; } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - if(!optionsBuilder.IsConfigured) + /// + /// Gets or sets the set of statistics. + /// + public DbSet StatisticsSet { get; set; } + + /// + /// Gets or sets the set of trainings. + /// + public DbSet TrainingsSet { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public LibraryContext() : base() { } + + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public LibraryContext(DbContextOptions options) : base(options) { } + + /// + /// Configures the database options if they are not already configured. + /// + /// The options builder instance. + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db"); + if (!optionsBuilder.IsConfigured) + { + optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db"); + } } - } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); + /// + /// Configures the model for the library context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + } } -} +} \ No newline at end of file diff --git a/src/Entities/ActivityEntity.cs b/src/Entities/ActivityEntity.cs index e3ae0e7..1f89d06 100644 --- a/src/Entities/ActivityEntity.cs +++ b/src/Entities/ActivityEntity.cs @@ -1,35 +1,100 @@ +//----------------------------------------------------------------------- +// FILENAME: ActivityEntity.cs +// PROJECT: Entities +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Entities; +namespace Entities +{ + /// + /// Represents an activity entity in the database. + /// + [Table("Activity")] + public class ActivityEntity + { + /// + /// Gets or sets the unique identifier of the activity. + /// + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdActivity { get; set; } + + /// + /// Gets or sets the type of the activity. + /// + [Required] + [MaxLength(100)] + public string Type { get; set; } + /// + /// Gets or sets the date of the activity. + /// + [Required(ErrorMessage = "Activity Date is required")] + [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] + public DateOnly Date { get; set; } -[Table("Activity")] -public class ActivityEntity -{ - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int IdActivity { get; set; } - [Required] - [MaxLength(100)] - public required string Type { get; set; } - [Required(ErrorMessage = "Activity Date is required")] - // [DataType(DataType.DateTime)] - [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] - public DateOnly Date { get; set; } - [Required(ErrorMessage = "Start Activity Hour is required")] - [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] - public TimeOnly StartTime { get; set; } - [Required(ErrorMessage = "End Activity Hour is required")] - [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] - public TimeOnly EndTime { get; set; } - public int EffortFelt { get; set; } - public float Variability { get; set; } - public float Variance { get; set; } - public float StandardDeviation { get; set; } - public float Average { get; set; } - public int Maximum { get; set; } - public int Minimum { get; set; } - public float AverageTemperature { get; set; } - public bool HasAutoPause { get; set; } + /// + /// Gets or sets the start time of the activity. + /// + [Required(ErrorMessage = "Start Activity Hour is required")] + [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] + public TimeOnly StartTime { get; set; } + + /// + /// Gets or sets the end time of the activity. + /// + [Required(ErrorMessage = "End Activity Hour is required")] + [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] + public TimeOnly EndTime { get; set; } + + /// + /// Gets or sets the perceived effort of the activity. + /// + public int EffortFelt { get; set; } + + /// + /// Gets or sets the variability of the activity. + /// + public float Variability { get; set; } + + /// + /// Gets or sets the variance of the activity. + /// + public float Variance { get; set; } + + /// + /// Gets or sets the standard deviation of the activity. + /// + public float StandardDeviation { get; set; } + + /// + /// Gets or sets the average of the activity. + /// + public float Average { get; set; } + + /// + /// Gets or sets the maximum value of the activity. + /// + public int Maximum { get; set; } + + /// + /// Gets or sets the minimum value of the activity. + /// + public int Minimum { get; set; } + + /// + /// Gets or sets the average temperature during the activity. + /// + public float AverageTemperature { get; set; } + + /// + /// Gets or sets whether the activity has an automatic pause feature. + /// + public bool HasAutoPause { get; set; } + } } \ No newline at end of file diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index 17d2d86..7138fd8 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -1,32 +1,90 @@ +//----------------------------------------------------------------------- +// FILENAME: AthleteEntity.cs +// PROJECT: Entities +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Entities; - -[Table("Athlete")] -public class AthleteEntity +namespace Entities { - // ! donner plus de contraintes !! - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int IdAthlete { get; set; } - [Required] - [MaxLength(100)] - public required string Username { get; set; } - [MaxLength(100)] - public required string LastName { get; set; } - [MaxLength(150)] - public required string FirstName { get; set; } - [MaxLength(100)] - public required string Email { get; set; } - [MaxLength(1)] - public required string Sexe { get; set; } - public double Lenght { get; set; } - public float Weight { get; set; } - public required string Password { get; set; } - - [Required(ErrorMessage = "Athlete Date of Birth is required")] - [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] - public DateOnly DateOfBirth { get; set; } - public bool IsCoach { get; set; } + /// + /// Represents an athlete entity in the database. + /// + [Table("Athlete")] + public class AthleteEntity + { + /// + /// Gets or sets the unique identifier of the athlete. + /// + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdAthlete { get; set; } + + /// + /// Gets or sets the username of the athlete. + /// + [MaxLength(100)] + [Required(ErrorMessage = "Athlete Username is required")] + public required string Username { get; set; } + + /// + /// Gets or sets the last name of the athlete. + /// + [MaxLength(100)] + [Required(ErrorMessage = "Athlete Last Name is required")] + public required string LastName { get; set; } + + /// + /// Gets or sets the first name of the athlete. + /// + [MaxLength(150)] + [Required(ErrorMessage = "Athlete First Name is required")] + public required string FirstName { get; set; } + + /// + /// Gets or sets the email of the athlete. + /// + [MaxLength(100)] + [Required(ErrorMessage = "Athlete Email is required")] + public required string Email { get; set; } + + /// + /// Gets or sets the gender of the athlete. + /// + [MaxLength(1)] + [Required(ErrorMessage = "Athlete Sexe is required")] + public required string Sexe { get; set; } + + /// + /// Gets or sets the height of the athlete. + /// + public double Length { get; set; } + + /// + /// Gets or sets the weight of the athlete. + /// + public float Weight { get; set; } + + /// + /// Gets or sets the password of the athlete. + /// + [Required(ErrorMessage = "Athlete Password is required")] + public required string Password { get; set; } + + /// + /// Gets or sets the date of birth of the athlete. + /// + [Required(ErrorMessage = "Athlete Date of Birth is required")] + [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] + public DateOnly DateOfBirth { get; set; } + + /// + /// Gets or sets whether the athlete is a coach. + /// + public bool IsCoach { get; set; } + } } \ No newline at end of file diff --git a/src/Entities/DataSourceEntity.cs b/src/Entities/DataSourceEntity.cs index e13a0ea..37d339a 100644 --- a/src/Entities/DataSourceEntity.cs +++ b/src/Entities/DataSourceEntity.cs @@ -1,17 +1,46 @@ +//----------------------------------------------------------------------- +// FILENAME: DataSourceEntity.cs +// PROJECT: Entities +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Entities; - -[Table("DataSource")] -public class DataSourceEntity +namespace Entities { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int IdSource { get; set; } - [MaxLength(100)] - public required string Type { get; set; } - [MaxLength(100)] - public required string Modele { get; set; } - public float Precision { get; set; } + /// + /// Represents a data source entity in the database. + /// + [Table("DataSource")] + public class DataSourceEntity + { + /// + /// Gets or sets the unique identifier of the data source. + /// + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdSource { get; set; } + + /// + /// Gets or sets the type of the data source. + /// + [MaxLength(100)] + [Required] + public required string Type { get; set; } + + /// + /// Gets or sets the model of the data source. + /// + [MaxLength(100)] + [Required] + public required string Model { get; set; } + + /// + /// Gets or sets the precision of the data source. + /// + public float Precision { get; set; } + } } \ No newline at end of file diff --git a/src/Entities/HeartRateEntity.cs b/src/Entities/HeartRateEntity.cs index ed3651c..3e11017 100644 --- a/src/Entities/HeartRateEntity.cs +++ b/src/Entities/HeartRateEntity.cs @@ -1,20 +1,59 @@ +//----------------------------------------------------------------------- +// FILENAME: HeartRateEntity.cs +// PROJECT: Entities +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Entities; - -[Table("HeartRate")] -public class HeartRateEntity +namespace Entities { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int IdHeartRate { get; set; } - public double Altitude { get; set; } - [Required(ErrorMessage = "HeartRate Time is required")] - [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] - public TimeOnly Time { get; set; } - public float Temperature { get; set; } - public int Bpm { get; set; } - public float Longitude { get; set; } - public float Latitude { get; set; } + /// + /// Represents a heart rate entity in the database. + /// + [Table("HeartRate")] + public class HeartRateEntity + { + /// + /// Gets or sets the unique identifier of the heart rate entry. + /// + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdHeartRate { get; set; } + + /// + /// Gets or sets the altitude. + /// + public double Altitude { get; set; } + + /// + /// Gets or sets the time of the heart rate measurement. + /// + [Required(ErrorMessage = "HeartRate Time is required")] + [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] + public TimeOnly Time { get; set; } + + /// + /// Gets or sets the temperature. + /// + public float Temperature { get; set; } + + /// + /// Gets or sets the heart rate in beats per minute (bpm). + /// + public int Bpm { get; set; } + + /// + /// Gets or sets the longitude. + /// + public float Longitude { get; set; } + + /// + /// Gets or sets the latitude. + /// + public float Latitude { get; set; } + } } \ No newline at end of file diff --git a/src/Entities/NotificationEntity.cs b/src/Entities/NotificationEntity.cs index 058b0a7..1d93b99 100644 --- a/src/Entities/NotificationEntity.cs +++ b/src/Entities/NotificationEntity.cs @@ -1,21 +1,52 @@ +//----------------------------------------------------------------------- +// FILENAME: NotificationEntity.cs +// PROJECT: Entities +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Entities; - -[Table("Notification")] -public class NotificationEntity +namespace Entities { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int IdNotif { get; set; } - [MaxLength(100)] - [Required] // dire obligatoire dans la base de données - public string Message { get; set; } = null!; // pour dire pas null - [Required(ErrorMessage = "Notification Date is required")] - [DisplayFormat(DataFormatString = "{0:HH.mm.ss - HH.mm.ss}", ApplyFormatInEditMode = true)] - public DateTime Date { get; set; } - public bool Statut { get; set; } - [MaxLength(100)] - public required string Urgence { get; set; } + /// + /// Represents a notification entity in the database. + /// + [Table("Notification")] + public class NotificationEntity + { + /// + /// Gets or sets the unique identifier of the notification. + /// + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdNotif { get; set; } + + /// + /// Gets or sets the message of the notification. + /// + [MaxLength(100)] + [Required(ErrorMessage = "Message is required")] + public string Message { get; set; } = null!; + + /// + /// Gets or sets the date of the notification. + /// + [Required(ErrorMessage = "Notification Date is required")] + [DisplayFormat(DataFormatString = "{0:HH.mm.ss - HH.mm.ss}", ApplyFormatInEditMode = true)] + public DateTime Date { get; set; } + + /// + /// Gets or sets the status of the notification. + /// + public bool Statut { get; set; } + + /// + /// Gets or sets the urgency of the notification. + /// + [MaxLength(100)] + public string Urgence { get; set; } = null!; + } } \ No newline at end of file diff --git a/src/Entities/StatisticEntity.cs b/src/Entities/StatisticEntity.cs index 340b76e..f3e8381 100644 --- a/src/Entities/StatisticEntity.cs +++ b/src/Entities/StatisticEntity.cs @@ -1,19 +1,54 @@ +//----------------------------------------------------------------------- +// FILENAME: StatisticEntity.cs +// PROJECT: Entities +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Entities; - -[Table("Statistic")] -public class StatisticEntity +namespace Entities { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int IdStatistic { get; set; } - public float Weight { get; set; } - public double AverageHeartRate { get; set; } - public double MaximumHeartRate { get; set; } - public double AverageCaloriesBurned { get; set; } - [Required(ErrorMessage = "Satistic Date is required")] - [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] - public DateOnly Date { get; set; } + /// + /// Represents a statistic entity in the database. + /// + [Table("Statistic")] + public class StatisticEntity + { + /// + /// Gets or sets the unique identifier of the statistic. + /// + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdStatistic { get; set; } + + /// + /// Gets or sets the weight recorded in the statistic. + /// + public float Weight { get; set; } + + /// + /// Gets or sets the average heart rate recorded in the statistic. + /// + public double AverageHeartRate { get; set; } + + /// + /// Gets or sets the maximum heart rate recorded in the statistic. + /// + public double MaximumHeartRate { get; set; } + + /// + /// Gets or sets the average calories burned recorded in the statistic. + /// + public double AverageCaloriesBurned { get; set; } + + /// + /// Gets or sets the date of the statistic. + /// + [Required(ErrorMessage = "Statistic Date is required")] + [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] + public DateOnly Date { get; set; } + } } \ No newline at end of file diff --git a/src/Entities/TrainingEntity.cs b/src/Entities/TrainingEntity.cs index 0a057bc..ca5e0f8 100644 --- a/src/Entities/TrainingEntity.cs +++ b/src/Entities/TrainingEntity.cs @@ -1,23 +1,56 @@ +//----------------------------------------------------------------------- +// FILENAME: TrainingEntity.cs +// PROJECT: Entities +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Runtime.CompilerServices; - -namespace Entities; -[Table("Training")] -public class TrainingEntity +namespace Entities { - // ! donner plus de contraintes !! - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int IdTraining { get; set; } - [Required(ErrorMessage = "Training Date is required")] - [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] - public DateOnly Date { get; set; } - [MaxLength(300)] - public string? Description { get; set; } - public float Latitude { get; set; } - public float Longitude { get; set; } - [MaxLength(300)] - public string? FeedBack { get; set; } + /// + /// Represents a training entity in the database. + /// + [Table("Training")] + public class TrainingEntity + { + /// + /// Gets or sets the unique identifier of the training. + /// + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdTraining { get; set; } + + /// + /// Gets or sets the date of the training. + /// + [Required(ErrorMessage = "Training Date is required")] + [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] + public DateOnly Date { get; set; } + + /// + /// Gets or sets the description of the training. + /// + [MaxLength(300)] + public string? Description { get; set; } + + /// + /// Gets or sets the latitude of the training location. + /// + public float Latitude { get; set; } + + /// + /// Gets or sets the longitude of the training location. + /// + public float Longitude { get; set; } + + /// + /// Gets or sets the feedback for the training. + /// + [MaxLength(300)] + public string? FeedBack { get; set; } + } } \ No newline at end of file diff --git a/src/StubbedContextLib/ActivityStubbedContext.cs b/src/StubbedContextLib/ActivityStubbedContext.cs index d97cfdf..1eddac9 100644 --- a/src/StubbedContextLib/ActivityStubbedContext.cs +++ b/src/StubbedContextLib/ActivityStubbedContext.cs @@ -1,31 +1,51 @@ +//----------------------------------------------------------------------- +// FILENAME: ActivityStubbedContext.cs +// PROJECT: StubbedContextLib +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using DbContextLib; using Entities; using Microsoft.EntityFrameworkCore; -namespace StubbedContextLib; - -public class ActivityStubbedContext : LibraryContext +namespace StubbedContextLib { - public ActivityStubbedContext() - :base() - { } + /// + /// Represents a stubbed context for activities. + /// + public class ActivityStubbedContext : LibraryContext + { + /// + /// Initializes a new instance of the class. + /// + public ActivityStubbedContext() : base() { } - public ActivityStubbedContext(DbContextOptions options) - :base(options) - { } + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public ActivityStubbedContext(DbContextOptions options) : base(options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().HasData( - new ActivityEntity { IdActivity = 1, Type = "Running", Date = new DateOnly(2023, 01, 10), StartTime = new TimeOnly(13, 00, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, - new ActivityEntity { IdActivity = 2, Type = "Cycling", Date = new DateOnly(2023, 01, 25), StartTime = new TimeOnly(13, 04, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, - new ActivityEntity { IdActivity = 3, Type = "Swimming", Date = new DateOnly(2023, 12, 10), StartTime = new TimeOnly(13, 30, 34), EndTime = new TimeOnly(15, 02, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, - new ActivityEntity { IdActivity = 4, Type = "Walking", Date = new DateOnly(2024, 01, 02), StartTime = new TimeOnly(15, 00, 00), EndTime = new TimeOnly(16, 01, 55), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, - new ActivityEntity { IdActivity = 5, Type = "Hiking", Date = new DateOnly(2024, 01, 12), StartTime = new TimeOnly(07, 45, 34), EndTime = new TimeOnly(09, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, - new ActivityEntity { IdActivity = 6, Type = "Climbing", Date = new DateOnly(2024, 01, 27), StartTime = new TimeOnly(13, 30, 01), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, - new ActivityEntity { IdActivity = 7, Type = "Yoga", Date = new DateOnly(2024, 02, 22), StartTime = new TimeOnly(22, 00, 34), EndTime = new TimeOnly(23, 50, 58), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false } - ); + /// + /// Configures the model for the activity context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + // Seed data for activities + modelBuilder.Entity().HasData( + new ActivityEntity { IdActivity = 1, Type = "Running", Date = new DateOnly(2023, 01, 10), StartTime = new TimeOnly(13, 00, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, + new ActivityEntity { IdActivity = 2, Type = "Cycling", Date = new DateOnly(2023, 01, 25), StartTime = new TimeOnly(13, 04, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, + new ActivityEntity { IdActivity = 3, Type = "Swimming", Date = new DateOnly(2023, 12, 10), StartTime = new TimeOnly(13, 30, 34), EndTime = new TimeOnly(15, 02, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, + new ActivityEntity { IdActivity = 4, Type = "Walking", Date = new DateOnly(2024, 01, 02), StartTime = new TimeOnly(15, 00, 00), EndTime = new TimeOnly(16, 01, 55), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, + new ActivityEntity { IdActivity = 5, Type = "Hiking", Date = new DateOnly(2024, 01, 12), StartTime = new TimeOnly(07, 45, 34), EndTime = new TimeOnly(09, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, + new ActivityEntity { IdActivity = 6, Type = "Climbing", Date = new DateOnly(2024, 01, 27), StartTime = new TimeOnly(13, 30, 01), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }, + new ActivityEntity { IdActivity = 7, Type = "Yoga", Date = new DateOnly(2024, 02, 22), StartTime = new TimeOnly(22, 00, 34), EndTime = new TimeOnly(23, 50, 58), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false } + ); + } } } \ No newline at end of file diff --git a/src/StubbedContextLib/AthleteStubbedContext.cs b/src/StubbedContextLib/AthleteStubbedContext.cs index 2593eb7..cf1ea01 100644 --- a/src/StubbedContextLib/AthleteStubbedContext.cs +++ b/src/StubbedContextLib/AthleteStubbedContext.cs @@ -1,29 +1,48 @@ -using DbContextLib; +//----------------------------------------------------------------------- +// FILENAME: AthleteStubbedContext.cs +// PROJECT: StubbedContextLib +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + +using DbContextLib; using Entities; using Microsoft.EntityFrameworkCore; -namespace StubbedContextLib; - -public class AthleteStubbedContext : ActivityStubbedContext +namespace StubbedContextLib { - public AthleteStubbedContext() - :base() - { } + /// + /// Represents the stubbed context for athletes. + /// + public class AthleteStubbedContext : ActivityStubbedContext + { + /// + /// Initializes a new instance of the class. + /// + public AthleteStubbedContext() : base() { } - public AthleteStubbedContext(DbContextOptions options) - :base(options) - { } + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public AthleteStubbedContext(DbContextOptions options) : base(options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().HasData( - new AthleteEntity { IdAthlete = 1, Username = "Doe", LastName = "Doe", FirstName = "John", Email = "john.doe@example.com", Password = "password123", Sexe = "M", Lenght = 1.80, Weight = 75, DateOfBirth = new DateOnly(1990, 01, 01), IsCoach = true }, - new AthleteEntity { IdAthlete = 2, Username = "Smith", LastName = "Smith", FirstName = "Jane", Email = "jane.smith@exemple.com", Password = "secure456", Sexe = "F", Lenght = 1.65, Weight = 60, DateOfBirth = new DateOnly(1995, 01, 01), IsCoach = false }, - new AthleteEntity { IdAthlete = 3, Username = "Martin", LastName = "Martin", FirstName = "Paul", Email = "paul.martin@example.com", Password = "super789", Sexe = "M", Lenght = 1.75, Weight = 68, DateOfBirth = new DateOnly(1992, 01, 01), IsCoach = true }, - new AthleteEntity { IdAthlete = 4, Username = "Brown", LastName = "Brown", FirstName = "Anna", Email = "anna.brown@example.com", Password = "test000", Sexe = "F", Lenght = 1.70, Weight = 58, DateOfBirth = new DateOnly(1993, 01, 01), IsCoach = false }, - new AthleteEntity { IdAthlete = 5, Username = "Lee", LastName = "Lee", FirstName ="Bruce", Email = "bruce.lee@example.com", Password = "hello321", Sexe = "M", Lenght = 2.0, Weight = 90, DateOfBirth = new DateOnly(1991, 01, 01), IsCoach = false } - ); + /// + /// Configures the model for the athlete stubbed context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new AthleteEntity { IdAthlete = 1, Username = "Doe", LastName = "Doe", FirstName = "John", Email = "john.doe@example.com", Password = "password123", Sexe = "M", Length = 1.80, Weight = 75, DateOfBirth = new DateOnly(1990, 01, 01), IsCoach = true }, + new AthleteEntity { IdAthlete = 2, Username = "Smith", LastName = "Smith", FirstName = "Jane", Email = "jane.smith@exemple.com", Password = "secure456", Sexe = "F", Length = 1.65, Weight = 60, DateOfBirth = new DateOnly(1995, 01, 01), IsCoach = false }, + new AthleteEntity { IdAthlete = 3, Username = "Martin", LastName = "Martin", FirstName = "Paul", Email = "paul.martin@example.com", Password = "super789", Sexe = "M", Length = 1.75, Weight = 68, DateOfBirth = new DateOnly(1992, 01, 01), IsCoach = true }, + new AthleteEntity { IdAthlete = 4, Username = "Brown", LastName = "Brown", FirstName = "Anna", Email = "anna.brown@example.com", Password = "test000", Sexe = "F", Length = 1.70, Weight = 58, DateOfBirth = new DateOnly(1993, 01, 01), IsCoach = false }, + new AthleteEntity { IdAthlete = 5, Username = "Lee", LastName = "Lee", FirstName = "Bruce", Email = "bruce.lee@example.com", Password = "hello321", Sexe = "M", Length = 2.0, Weight = 90, DateOfBirth = new DateOnly(1991, 01, 01), IsCoach = false } + ); + } } } \ No newline at end of file diff --git a/src/StubbedContextLib/DataSourceStubbedContext.cs b/src/StubbedContextLib/DataSourceStubbedContext.cs index a9d0472..a34a80a 100644 --- a/src/StubbedContextLib/DataSourceStubbedContext.cs +++ b/src/StubbedContextLib/DataSourceStubbedContext.cs @@ -1,29 +1,48 @@ +//----------------------------------------------------------------------- +// FILENAME: DataSourceStubbedContext.cs +// PROJECT: StubbedContextLib +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using DbContextLib; using Entities; using Microsoft.EntityFrameworkCore; -namespace StubbedContextLib; - -public class DataSourceStubbedContext : AthleteStubbedContext +namespace StubbedContextLib { - public DataSourceStubbedContext() - :base() - { } + /// + /// Represents the stubbed context for data sources. + /// + public class DataSourceStubbedContext : AthleteStubbedContext + { + /// + /// Initializes a new instance of the class. + /// + public DataSourceStubbedContext() : base() { } - public DataSourceStubbedContext(DbContextOptions options) - :base(options) - { } + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public DataSourceStubbedContext(DbContextOptions options) : base(options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().HasData( - new DataSourceEntity { IdSource = 1, Type = "Smartwatch", Modele = "Garmin", Precision = 0.5f }, - new DataSourceEntity { IdSource = 2, Type = "Smartwatch", Modele = "Polar", Precision = 0.5f }, - new DataSourceEntity { IdSource = 3, Type = "Smartwatch", Modele = "Suunto", Precision = 0.5f }, - new DataSourceEntity { IdSource = 4, Type = "Smartwatch", Modele = "Fitbit", Precision = 0.5f }, - new DataSourceEntity { IdSource = 5, Type = "Smartwatch", Modele = "Apple Watch", Precision = 0.5f } - ); + /// + /// Configures the model for the data source stubbed context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new DataSourceEntity { IdSource = 1, Type = "Smartwatch", Model = "Garmin", Precision = 0.5f }, + new DataSourceEntity { IdSource = 2, Type = "Smartwatch", Model = "Polar", Precision = 0.5f }, + new DataSourceEntity { IdSource = 3, Type = "Smartwatch", Model = "Suunto", Precision = 0.5f }, + new DataSourceEntity { IdSource = 4, Type = "Smartwatch", Model = "Fitbit", Precision = 0.5f }, + new DataSourceEntity { IdSource = 5, Type = "Smartwatch", Model = "Apple Watch", Precision = 0.5f } + ); + } } } \ No newline at end of file diff --git a/src/StubbedContextLib/HeartRateStubbedContext.cs b/src/StubbedContextLib/HeartRateStubbedContext.cs index 8c71e01..501302a 100644 --- a/src/StubbedContextLib/HeartRateStubbedContext.cs +++ b/src/StubbedContextLib/HeartRateStubbedContext.cs @@ -1,29 +1,48 @@ +//----------------------------------------------------------------------- +// FILENAME: HeartRateStubbedContext.cs +// PROJECT: StubbedContextLib +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using DbContextLib; using Entities; using Microsoft.EntityFrameworkCore; -namespace StubbedContextLib; - -public class HeartRateStubbedContext : DataSourceStubbedContext +namespace StubbedContextLib { - public HeartRateStubbedContext() - :base() - { } + /// + /// Represents the stubbed context for heart rate entities. + /// + public class HeartRateStubbedContext : DataSourceStubbedContext + { + /// + /// Initializes a new instance of the class. + /// + public HeartRateStubbedContext() : base() { } - public HeartRateStubbedContext(DbContextOptions options) - :base(options) - { } + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public HeartRateStubbedContext(DbContextOptions options) : base(options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().HasData( - new HeartRateEntity { IdHeartRate = 1, Altitude = 0.0, Time = new TimeOnly(13, 00, 30), Temperature = 20.0f, Bpm = 60, Longitude = 35f, Latitude = 66f }, - new HeartRateEntity { IdHeartRate = 2, Altitude = 10, Time = new TimeOnly(13, 00, 31), Temperature = 20.5f, Bpm = 65, Longitude = 35f, Latitude = 67f }, - new HeartRateEntity { IdHeartRate = 3, Altitude = 11, Time = new TimeOnly(13, 00, 32), Temperature = 20.0f, Bpm = 71, Longitude = 36f, Latitude = 66f }, - new HeartRateEntity { IdHeartRate = 4, Altitude = 12, Time = new TimeOnly(13, 00, 33), Temperature = 20.5f, Bpm = 75, Longitude = 36f, Latitude = 67f }, - new HeartRateEntity { IdHeartRate = 5, Altitude = 13, Time = new TimeOnly(13, 00, 34), Temperature = 20.0f, Bpm = 80, Longitude = 37f, Latitude = 66f } - ); + /// + /// Configures the model for the heart rate stubbed context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new HeartRateEntity { IdHeartRate = 1, Altitude = 0.0, Time = new TimeOnly(13, 00, 30), Temperature = 20.0f, Bpm = 60, Longitude = 35f, Latitude = 66f }, + new HeartRateEntity { IdHeartRate = 2, Altitude = 10, Time = new TimeOnly(13, 00, 31), Temperature = 20.5f, Bpm = 65, Longitude = 35f, Latitude = 67f }, + new HeartRateEntity { IdHeartRate = 3, Altitude = 11, Time = new TimeOnly(13, 00, 32), Temperature = 20.0f, Bpm = 71, Longitude = 36f, Latitude = 66f }, + new HeartRateEntity { IdHeartRate = 4, Altitude = 12, Time = new TimeOnly(13, 00, 33), Temperature = 20.5f, Bpm = 75, Longitude = 36f, Latitude = 67f }, + new HeartRateEntity { IdHeartRate = 5, Altitude = 13, Time = new TimeOnly(13, 00, 34), Temperature = 20.0f, Bpm = 80, Longitude = 37f, Latitude = 66f } + ); + } } } \ No newline at end of file diff --git a/src/StubbedContextLib/Migrations/20240222102358_MyMigrations.Designer.cs b/src/StubbedContextLib/Migrations/20240222104952_MyMigrations.Designer.cs similarity index 97% rename from src/StubbedContextLib/Migrations/20240222102358_MyMigrations.Designer.cs rename to src/StubbedContextLib/Migrations/20240222104952_MyMigrations.Designer.cs index 3337f41..08cb864 100644 --- a/src/StubbedContextLib/Migrations/20240222102358_MyMigrations.Designer.cs +++ b/src/StubbedContextLib/Migrations/20240222104952_MyMigrations.Designer.cs @@ -11,7 +11,7 @@ using StubbedContextLib; namespace StubbedContextLib.Migrations { [DbContext(typeof(TrainingStubbedContext))] - [Migration("20240222102358_MyMigrations")] + [Migration("20240222104952_MyMigrations")] partial class MyMigrations { /// @@ -220,7 +220,7 @@ namespace StubbedContextLib.Migrations .HasMaxLength(100) .HasColumnType("TEXT"); - b.Property("Lenght") + b.Property("Length") .HasColumnType("REAL"); b.Property("Password") @@ -253,7 +253,7 @@ namespace StubbedContextLib.Migrations FirstName = "John", IsCoach = true, LastName = "Doe", - Lenght = 1.8, + Length = 1.8, Password = "password123", Sexe = "M", Username = "Doe", @@ -267,7 +267,7 @@ namespace StubbedContextLib.Migrations FirstName = "Jane", IsCoach = false, LastName = "Smith", - Lenght = 1.6499999999999999, + Length = 1.6499999999999999, Password = "secure456", Sexe = "F", Username = "Smith", @@ -281,7 +281,7 @@ namespace StubbedContextLib.Migrations FirstName = "Paul", IsCoach = true, LastName = "Martin", - Lenght = 1.75, + Length = 1.75, Password = "super789", Sexe = "M", Username = "Martin", @@ -295,7 +295,7 @@ namespace StubbedContextLib.Migrations FirstName = "Anna", IsCoach = false, LastName = "Brown", - Lenght = 1.7, + Length = 1.7, Password = "test000", Sexe = "F", Username = "Brown", @@ -309,7 +309,7 @@ namespace StubbedContextLib.Migrations FirstName = "Bruce", IsCoach = false, LastName = "Lee", - Lenght = 2.0, + Length = 2.0, Password = "hello321", Sexe = "M", Username = "Lee", @@ -323,7 +323,7 @@ namespace StubbedContextLib.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("Modele") + b.Property("Model") .IsRequired() .HasMaxLength(100) .HasColumnType("TEXT"); @@ -344,35 +344,35 @@ namespace StubbedContextLib.Migrations new { IdSource = 1, - Modele = "Garmin", + Model = "Garmin", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 2, - Modele = "Polar", + Model = "Polar", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 3, - Modele = "Suunto", + Model = "Suunto", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 4, - Modele = "Fitbit", + Model = "Fitbit", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 5, - Modele = "Apple Watch", + Model = "Apple Watch", Precision = 0.5f, Type = "Smartwatch" }); diff --git a/src/StubbedContextLib/Migrations/20240222102358_MyMigrations.cs b/src/StubbedContextLib/Migrations/20240222104952_MyMigrations.cs similarity index 97% rename from src/StubbedContextLib/Migrations/20240222102358_MyMigrations.cs rename to src/StubbedContextLib/Migrations/20240222104952_MyMigrations.cs index 39001c0..ef7f153 100644 --- a/src/StubbedContextLib/Migrations/20240222102358_MyMigrations.cs +++ b/src/StubbedContextLib/Migrations/20240222104952_MyMigrations.cs @@ -49,7 +49,7 @@ namespace StubbedContextLib.Migrations FirstName = table.Column(type: "TEXT", maxLength: 150, nullable: false), Email = table.Column(type: "TEXT", maxLength: 100, nullable: false), Sexe = table.Column(type: "TEXT", maxLength: 1, nullable: false), - Lenght = table.Column(type: "REAL", nullable: false), + Length = table.Column(type: "REAL", nullable: false), Weight = table.Column(type: "REAL", nullable: false), Password = table.Column(type: "TEXT", nullable: false), DateOfBirth = table.Column(type: "TEXT", nullable: false), @@ -67,7 +67,7 @@ namespace StubbedContextLib.Migrations IdSource = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Type = table.Column(type: "TEXT", maxLength: 100, nullable: false), - Modele = table.Column(type: "TEXT", maxLength: 100, nullable: false), + Model = table.Column(type: "TEXT", maxLength: 100, nullable: false), Precision = table.Column(type: "REAL", nullable: false) }, constraints: table => @@ -159,7 +159,7 @@ namespace StubbedContextLib.Migrations migrationBuilder.InsertData( table: "Athlete", - columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Lenght", "Password", "Sexe", "Username", "Weight" }, + columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "Sexe", "Username", "Weight" }, values: new object[,] { { 1, new DateOnly(1990, 1, 1), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f }, @@ -171,7 +171,7 @@ namespace StubbedContextLib.Migrations migrationBuilder.InsertData( table: "DataSource", - columns: new[] { "IdSource", "Modele", "Precision", "Type" }, + columns: new[] { "IdSource", "Model", "Precision", "Type" }, values: new object[,] { { 1, "Garmin", 0.5f, "Smartwatch" }, diff --git a/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs b/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs index b1ab193..cbca83e 100644 --- a/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs +++ b/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs @@ -217,7 +217,7 @@ namespace StubbedContextLib.Migrations .HasMaxLength(100) .HasColumnType("TEXT"); - b.Property("Lenght") + b.Property("Length") .HasColumnType("REAL"); b.Property("Password") @@ -250,7 +250,7 @@ namespace StubbedContextLib.Migrations FirstName = "John", IsCoach = true, LastName = "Doe", - Lenght = 1.8, + Length = 1.8, Password = "password123", Sexe = "M", Username = "Doe", @@ -264,7 +264,7 @@ namespace StubbedContextLib.Migrations FirstName = "Jane", IsCoach = false, LastName = "Smith", - Lenght = 1.6499999999999999, + Length = 1.6499999999999999, Password = "secure456", Sexe = "F", Username = "Smith", @@ -278,7 +278,7 @@ namespace StubbedContextLib.Migrations FirstName = "Paul", IsCoach = true, LastName = "Martin", - Lenght = 1.75, + Length = 1.75, Password = "super789", Sexe = "M", Username = "Martin", @@ -292,7 +292,7 @@ namespace StubbedContextLib.Migrations FirstName = "Anna", IsCoach = false, LastName = "Brown", - Lenght = 1.7, + Length = 1.7, Password = "test000", Sexe = "F", Username = "Brown", @@ -306,7 +306,7 @@ namespace StubbedContextLib.Migrations FirstName = "Bruce", IsCoach = false, LastName = "Lee", - Lenght = 2.0, + Length = 2.0, Password = "hello321", Sexe = "M", Username = "Lee", @@ -320,7 +320,7 @@ namespace StubbedContextLib.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("Modele") + b.Property("Model") .IsRequired() .HasMaxLength(100) .HasColumnType("TEXT"); @@ -341,35 +341,35 @@ namespace StubbedContextLib.Migrations new { IdSource = 1, - Modele = "Garmin", + Model = "Garmin", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 2, - Modele = "Polar", + Model = "Polar", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 3, - Modele = "Suunto", + Model = "Suunto", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 4, - Modele = "Fitbit", + Model = "Fitbit", Precision = 0.5f, Type = "Smartwatch" }, new { IdSource = 5, - Modele = "Apple Watch", + Model = "Apple Watch", Precision = 0.5f, Type = "Smartwatch" }); diff --git a/src/StubbedContextLib/NotificationStubbedContext.cs b/src/StubbedContextLib/NotificationStubbedContext.cs index 6af02f2..ce55815 100644 --- a/src/StubbedContextLib/NotificationStubbedContext.cs +++ b/src/StubbedContextLib/NotificationStubbedContext.cs @@ -1,29 +1,48 @@ +//----------------------------------------------------------------------- +// FILENAME: NotificationStubbedContext.cs +// PROJECT: StubbedContextLib +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using DbContextLib; using Entities; using Microsoft.EntityFrameworkCore; -namespace StubbedContextLib; - -public class NotificationStubbedContext : HeartRateStubbedContext +namespace StubbedContextLib { - public NotificationStubbedContext() - :base() - { } + /// + /// Represents the stubbed context for notification entities. + /// + public class NotificationStubbedContext : HeartRateStubbedContext + { + /// + /// Initializes a new instance of the class. + /// + public NotificationStubbedContext() : base() { } - public NotificationStubbedContext(DbContextOptions options) - :base(options) - { } + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public NotificationStubbedContext(DbContextOptions options) : base(options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().HasData( - new NotificationEntity { IdNotif = 1, Message = "You have a new activity to check", Date = new DateTime(2023, 12, 25, 13, 00, 40), Statut = true, Urgence = "A" }, - new NotificationEntity { IdNotif = 2, Message = "You have a new athlete to check", Date = new DateTime(2023, 12, 26, 13, 10, 40), Statut = false, Urgence = "3" }, - new NotificationEntity { IdNotif = 3, Message = "You have a new heart rate to check", Date = new DateTime(2023, 12, 26, 16, 10, 04), Statut = true, Urgence = "2" }, - new NotificationEntity { IdNotif = 4, Message = "You have a new data source to check", Date = new DateTime(2024, 01, 12, 09, 30, 50), Statut = false, Urgence = "1" }, - new NotificationEntity { IdNotif = 5, Message = "You have a new notification to check", Date = new DateTime(2024, 02, 22, 12, 10, 00), Statut = true, Urgence = "3" } - ); + /// + /// Configures the model for the notification stubbed context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new NotificationEntity { IdNotif = 1, Message = "You have a new activity to check", Date = new DateTime(2023, 12, 25, 13, 00, 40), Statut = true, Urgence = "A" }, + new NotificationEntity { IdNotif = 2, Message = "You have a new athlete to check", Date = new DateTime(2023, 12, 26, 13, 10, 40), Statut = false, Urgence = "3" }, + new NotificationEntity { IdNotif = 3, Message = "You have a new heart rate to check", Date = new DateTime(2023, 12, 26, 16, 10, 04), Statut = true, Urgence = "2" }, + new NotificationEntity { IdNotif = 4, Message = "You have a new data source to check", Date = new DateTime(2024, 01, 12, 09, 30, 50), Statut = false, Urgence = "1" }, + new NotificationEntity { IdNotif = 5, Message = "You have a new notification to check", Date = new DateTime(2024, 02, 22, 12, 10, 00), Statut = true, Urgence = "3" } + ); + } } } \ No newline at end of file diff --git a/src/StubbedContextLib/StatisticStubbedContext.cs b/src/StubbedContextLib/StatisticStubbedContext.cs index d7ffc4b..d4a3ae7 100644 --- a/src/StubbedContextLib/StatisticStubbedContext.cs +++ b/src/StubbedContextLib/StatisticStubbedContext.cs @@ -1,29 +1,48 @@ +//----------------------------------------------------------------------- +// FILENAME: StatisticStubbedContext.cs +// PROJECT: StubbedContextLib +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using DbContextLib; using Entities; using Microsoft.EntityFrameworkCore; -namespace StubbedContextLib; - -public class StatisticStubbedContext : NotificationStubbedContext +namespace StubbedContextLib { - public StatisticStubbedContext() - :base() - { } + /// + /// Represents the stubbed context for statistic entities. + /// + public class StatisticStubbedContext : NotificationStubbedContext + { + /// + /// Initializes a new instance of the class. + /// + public StatisticStubbedContext() : base() { } - public StatisticStubbedContext(DbContextOptions options) - :base(options) - { } + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public StatisticStubbedContext(DbContextOptions options) : base(options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().HasData( - new StatisticEntity { IdStatistic = 1, Weight = 75, AverageHeartRate = 120, MaximumHeartRate = 180, AverageCaloriesBurned = 500, Date = new DateOnly(2021, 12, 12) }, - new StatisticEntity { IdStatistic = 2, Weight = 60, AverageHeartRate = 130, MaximumHeartRate = 190, AverageCaloriesBurned = 600, Date = new DateOnly(2021, 01, 11) }, - new StatisticEntity { IdStatistic = 3, Weight = 68, AverageHeartRate = 125, MaximumHeartRate = 185, AverageCaloriesBurned = 550, Date = new DateOnly(2022, 12, 30) }, - new StatisticEntity { IdStatistic = 4, Weight = 58, AverageHeartRate = 135, MaximumHeartRate = 195, AverageCaloriesBurned = 650, Date = new DateOnly(2023, 02, 20) }, - new StatisticEntity { IdStatistic = 5, Weight = 90, AverageHeartRate = 110, MaximumHeartRate = 170, AverageCaloriesBurned = 450, Date = new DateOnly(2024, 01, 10) } - ); + /// + /// Configures the model for the statistic stubbed context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new StatisticEntity { IdStatistic = 1, Weight = 75, AverageHeartRate = 120, MaximumHeartRate = 180, AverageCaloriesBurned = 500, Date = new DateOnly(2021, 12, 12) }, + new StatisticEntity { IdStatistic = 2, Weight = 60, AverageHeartRate = 130, MaximumHeartRate = 190, AverageCaloriesBurned = 600, Date = new DateOnly(2021, 01, 11) }, + new StatisticEntity { IdStatistic = 3, Weight = 68, AverageHeartRate = 125, MaximumHeartRate = 185, AverageCaloriesBurned = 550, Date = new DateOnly(2022, 12, 30) }, + new StatisticEntity { IdStatistic = 4, Weight = 58, AverageHeartRate = 135, MaximumHeartRate = 195, AverageCaloriesBurned = 650, Date = new DateOnly(2023, 02, 20) }, + new StatisticEntity { IdStatistic = 5, Weight = 90, AverageHeartRate = 110, MaximumHeartRate = 170, AverageCaloriesBurned = 450, Date = new DateOnly(2024, 01, 10) } + ); + } } } \ No newline at end of file diff --git a/src/StubbedContextLib/TrainingStubbedContext.cs b/src/StubbedContextLib/TrainingStubbedContext.cs index b62df0e..6bc7cfe 100644 --- a/src/StubbedContextLib/TrainingStubbedContext.cs +++ b/src/StubbedContextLib/TrainingStubbedContext.cs @@ -1,29 +1,48 @@ +//----------------------------------------------------------------------- +// FILENAME: TrainingStubbedContext.cs +// PROJECT: StubbedContextLib +// SOLUTION: HeartTrack +// DATE CREATED: 22/02/2024 +// AUTHOR: Antoine PEREDERII +//----------------------------------------------------------------------- + using DbContextLib; using Entities; using Microsoft.EntityFrameworkCore; -namespace StubbedContextLib; - -public class TrainingStubbedContext : StatisticStubbedContext +namespace StubbedContextLib { - public TrainingStubbedContext() - :base() - { } + /// + /// Represents the stubbed context for training entities. + /// + public class TrainingStubbedContext : StatisticStubbedContext + { + /// + /// Initializes a new instance of the class. + /// + public TrainingStubbedContext() : base() { } - public TrainingStubbedContext(DbContextOptions options) - :base(options) - { } + /// + /// Initializes a new instance of the class with the specified options. + /// + /// The options for the context. + public TrainingStubbedContext(DbContextOptions options) : base(options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().HasData( - new TrainingEntity { IdTraining = 1, Date = new DateOnly(2024, 01, 19), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, - new TrainingEntity { IdTraining = 2, Date = new DateOnly(2024, 02, 20), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f }, - new TrainingEntity { IdTraining = 3, Date = new DateOnly(2024, 02, 21), Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, - new TrainingEntity { IdTraining = 4, Date = new DateOnly(2024, 02, 22), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, - new TrainingEntity { IdTraining = 5, Date = new DateOnly(2024, 02, 23), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f } - ); + /// + /// Configures the model for the training stubbed context. + /// + /// The model builder instance. + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new TrainingEntity { IdTraining = 1, Date = new DateOnly(2024, 01, 19), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, + new TrainingEntity { IdTraining = 2, Date = new DateOnly(2024, 02, 20), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f }, + new TrainingEntity { IdTraining = 3, Date = new DateOnly(2024, 02, 21), Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, + new TrainingEntity { IdTraining = 4, Date = new DateOnly(2024, 02, 22), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, + new TrainingEntity { IdTraining = 5, Date = new DateOnly(2024, 02, 23), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f } + ); + } } } \ No newline at end of file diff --git a/src/Tests/ConsoleTestEntities/Program.cs b/src/Tests/ConsoleTestEntities/Program.cs index e241e05..153f506 100644 --- a/src/Tests/ConsoleTestEntities/Program.cs +++ b/src/Tests/ConsoleTestEntities/Program.cs @@ -12,33 +12,33 @@ class Program try { using (LibraryContext db = new TrainingStubbedContext()) { - // AthletesTests(db); + AthletesTests(db); - // ActivityTests(db); + ActivityTests(db); - // DataSourceTests(db); + DataSourceTests(db); - // HeartRateTests(db); + HeartRateTests(db); - // NotificationTests(db); + NotificationTests(db); // StatisticTests(db); // TrainingTests(db); - AddUpdateDeleteAthlete(db); + // AddUpdateDeleteAthlete(db); - AddUpdateDeleteActivity(db); + // AddUpdateDeleteActivity(db); - AddUpdateDeleteDataSource(db); + // AddUpdateDeleteDataSource(db); - AddUpdateDeleteHeartRate(db); + // AddUpdateDeleteHeartRate(db); - AddUpdateDeleteNotification(db); + // AddUpdateDeleteNotification(db); - AddUpdateDeleteStatistic(db); + // AddUpdateDeleteStatistic(db); - AddUpdateDeleteTraining(db); + // AddUpdateDeleteTraining(db); } } catch (Exception ex) @@ -47,7 +47,6 @@ class Program } } - static void AthletesTests(LibraryContext db) { Console.WriteLine("Accès à tous les athletes :"); @@ -58,7 +57,7 @@ class Program foreach (var athlete in db.AthletesSet) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -67,7 +66,7 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.IdAthlete == 2)) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -76,7 +75,7 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.Username == "Doe")) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -85,7 +84,7 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.Sexe == "F")) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -94,7 +93,7 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.Email == "bruce.lee@example.com")) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -103,26 +102,25 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.Weight == 90)) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); Console.WriteLine("Accès à l'athlete de taille '1.80' :"); Console.WriteLine("---------------------------------"); - foreach (var athlete in db.AthletesSet.Where(a => a.Lenght == 1.80)) + foreach (var athlete in db.AthletesSet.Where(a => a.Length == 1.80)) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); - // ! A revoir !! - Console.WriteLine("Accès à l'athlete de date de naissance '01/01/2000' :"); + Console.WriteLine("Accès à l'athlete de date de naissance '01/01/1990' :"); Console.WriteLine("---------------------------------"); - foreach (var athlete in db.AthletesSet.Where(a => a.DateOfBirth == new DateOnly())) + foreach (var athlete in db.AthletesSet.Where(a => a.DateOfBirth == new DateOnly(1990, 01, 01))) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -131,7 +129,7 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.LastName == "Martin")) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -140,7 +138,7 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.FirstName == "Anna")) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -149,7 +147,7 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.LastName == "Brown" && a.FirstName == "Anna")) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); @@ -158,12 +156,12 @@ class Program Console.WriteLine("---------------------------------"); foreach (var athlete in db.AthletesSet.Where(a => a.IsCoach == true)) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } Console.WriteLine("---------------------------------\n"); } - + static void ActivityTests(LibraryContext db) { Console.WriteLine("Accès à toutes les activités :"); @@ -198,35 +196,85 @@ class Program Console.WriteLine("---------------------------------\n"); - Console.WriteLine("Accès à l'activité de date '01/01/2022' :"); + Console.WriteLine("Accès à l'activité de date '10/01/2023' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateOnly(2023, 01, 10))) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de temps '13:00:34' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34))) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running")) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10))) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22))) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' et de ressenti d'effort '5' :"); Console.WriteLine("---------------------------------"); - foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateOnly(2000,01, 01))) + foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22) && a.EffortFelt == 5)) { Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); } Console.WriteLine("---------------------------------\n"); - Console.WriteLine("Accès à l'activité de date '01/01/2022' et de type 'Running' :"); + Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' et de ressenti d'effort '5' et de variabilité '0.5' :"); Console.WriteLine("---------------------------------"); - foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateOnly(2022, 01, 01) && a.Type == "Running")) + foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22) && a.EffortFelt == 5 && a.Variability == 0.5F)) { Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); } Console.WriteLine("---------------------------------\n"); - // Console.WriteLine("Accès à l'activité de date '01/01/2022' et de type 'Running' et de StartTime '12:00:00' :"); - // Console.WriteLine("---------------------------------"); + Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' et de ressenti d'effort '5' et de variabilité '0.5' et de variance '0.5' :"); + Console.WriteLine("---------------------------------"); - // foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateTime(01/01/2022) && a.Type == "Running" && a.StartTime == new DateTime(12,00,00))) - // { - // Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); - // } + foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22) && a.EffortFelt == 5 && a.Variability == 0.5F && a.Variance == 0.5F)) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } - // Console.WriteLine("---------------------------------\n"); + Console.WriteLine("---------------------------------\n"); } static void DataSourceTests(LibraryContext db) @@ -238,7 +286,7 @@ class Program foreach (var dataSource in db.DataSourcesSet) { - Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); } Console.WriteLine("---------------------------------\n"); @@ -248,23 +296,52 @@ class Program foreach (var dataSource in db.DataSourcesSet.Where(d => d.IdSource == 2)) { - Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); } Console.WriteLine("---------------------------------\n"); - Console.WriteLine("Accès à la source de données de type 'Polar' :"); + Console.WriteLine("Accès à la source de données de type 'Smartwatch' :"); Console.WriteLine("---------------------------------"); - foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Polar")) + foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Smartwatch")) { - Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); } Console.WriteLine("---------------------------------\n"); - } + Console.WriteLine("Accès à la source de données de modèle 'Garmin' :"); + Console.WriteLine("---------------------------------"); + + foreach (var dataSource in db.DataSourcesSet.Where(d => d.Model == "Garmin")) + { + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la source de données de précision '0.5' :"); + Console.WriteLine("---------------------------------"); + + foreach (var dataSource in db.DataSourcesSet.Where(d => d.Precision == 0.5f)) + { + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); + } + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la source de données de type 'Smartwatch' et de modèle 'Garmin' :"); + Console.WriteLine("---------------------------------"); + + foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Smartwatch" && d.Model == "Garmin")) + { + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); + } + + Console.WriteLine("---------------------------------\n"); + } + static void HeartRateTests(LibraryContext db) { Console.WriteLine("Accès à toutes les fréquences cardiaques :"); @@ -288,6 +365,66 @@ class Program } Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la fréquence cardiaque d'altitude '10' :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet.Where(h => h.Altitude == 10)) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la fréquence cardiaque de température '20.5' :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet.Where(h => h.Temperature == 20.5f)) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la fréquence cardiaque de bpm '65' :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet.Where(h => h.Bpm == 65)) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la fréquence cardiaque de longitude '35' :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet.Where(h => h.Longitude == 35)) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la fréquence cardiaque de latitude '66' :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet.Where(h => h.Latitude == 66)) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la fréquence cardiaque d'altitude '10' et de température '20.5' :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet.Where(h => h.Altitude == 10 && h.Temperature == 20.5f)) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); } static void NotificationTests(LibraryContext db) @@ -313,6 +450,56 @@ class Program } Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la notification de message 'You have a new activity to check' :"); + Console.WriteLine("---------------------------------"); + + foreach (var notification in db.NotificationsSet.Where(n => n.Message == "You have a new activity to check")) + { + Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la notification de date '25/12/2023' :"); + Console.WriteLine("---------------------------------"); + + foreach (var notification in db.NotificationsSet.Where(n => n.Date == new DateTime(2023, 12, 25, 13, 00, 40))) + { + Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la notification de statut 'true' :"); + Console.WriteLine("---------------------------------"); + + foreach (var notification in db.NotificationsSet.Where(n => n.Statut == true)) + { + Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la notification d'urgence 'A' :"); + Console.WriteLine("---------------------------------"); + + foreach (var notification in db.NotificationsSet.Where(n => n.Urgence == "A")) + { + Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la notification de message 'You have a new activity to check' et de date '25/12/2023' :"); + Console.WriteLine("---------------------------------"); + + foreach (var notification in db.NotificationsSet.Where(n => n.Message == "You have a new activity to check" && n.Date == new DateTime(2023, 12, 25, 13, 00, 40))) + { + Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}"); + } + + Console.WriteLine("---------------------------------\n"); } static void StatisticTests(LibraryContext db) @@ -338,6 +525,116 @@ class Program } Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de poids '60' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de fréquence cardiaque moyenne '130' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.AverageHeartRate == 130)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de fréquence cardiaque maximale '190' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.MaximumHeartRate == 190)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de calories brûlées en moyenne '550' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.AverageCaloriesBurned == 550)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de date '30/12/2022' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Date == new DateOnly(2022, 12, 30))) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' et de date '11/01/2021' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600 && s.Date == new DateOnly(2021, 01, 11))) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' et de date '11/01/2021' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600 && s.Date == new DateOnly(2021, 01, 11))) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' et de date '11/01/2021' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600 && s.Date == new DateOnly(2021, 01, 11))) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); } static void TrainingTests(LibraryContext db) { @@ -362,6 +659,96 @@ class Program } Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de date '21/02/2024' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 21))) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de description 'Running' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Description == "Running")) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de latitude '48.8566f' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Latitude == 48.8566f)) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de longitude '2.3522f' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Longitude == 2.3522f)) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de feedback 'Good' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.FeedBack == "Good")) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de date '20/02/2024' et de description 'Cycling' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 20) && t.Description == "Cycling")) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de date '22/02/2024' et de description 'Running' et de latitude '48.8566f' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 22) && t.Description == "Running" && t.Latitude == 48.8566f)) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de date '23/02/2024' et de description 'Cycling' et de latitude '48.8566f' et de longitude '2.3522f' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 23) && t.Description == "Cycling" && t.Latitude == 48.8566f && t.Longitude == 2.3522f)) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement de date '19/01/2024' et de description 'Running' et de latitude '48.8566f' et de longitude '2.3522f' et de feedback 'Good' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 01, 19) && t.Description == "Running" && t.Latitude == 48.8566f && t.Longitude == 2.3522f && t.FeedBack == "Good")) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); } static void AddUpdateDeleteAthlete(LibraryContext db) @@ -369,7 +756,7 @@ class Program Console.WriteLine("Test d'ajout, de modification et de suppression des athletes :"); // Ajout d'un nouveau livre - var newAthlete = new AthleteEntity { Username = "Doe", LastName = "Doe", FirstName = "John", Email = "essaie.example.com", Password = "TheNewPassword", Sexe = "M", Lenght = 1.80, Weight = 90, DateOfBirth = new DateOnly(2024, 02, 22), IsCoach = false }; + var newAthlete = new AthleteEntity { Username = "Doe", LastName = "Doe", FirstName = "John", Email = "essaie.example.com", Password = "TheNewPassword", Sexe = "M", Length = 1.80, Weight = 90, DateOfBirth = new DateOnly(2024, 02, 22), IsCoach = false }; db.AthletesSet.Add(newAthlete); db.SaveChanges(); @@ -377,7 +764,7 @@ class Program Console.WriteLine("Athlete après ajout :"); foreach (var athlete in db.AthletesSet) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } // Modification du titre du nouveau livre @@ -388,7 +775,7 @@ class Program Console.WriteLine("Livres après modification :"); foreach (var athlete in db.AthletesSet) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } // Suppression du nouveau livre @@ -399,7 +786,7 @@ class Program Console.WriteLine("Livres après suppression :"); foreach (var athlete in db.AthletesSet) { - Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); + Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}"); } } @@ -441,14 +828,14 @@ class Program { Console.WriteLine("Test d'ajout, de modification et de suppression des sources de données :"); - var newDataSource = new DataSourceEntity { Type = "Polar", Modele = "Polar Vantage V2", Precision = 0.5F }; + var newDataSource = new DataSourceEntity { Type = "Polar", Model = "Polar Vantage V2", Precision = 0.5F }; db.DataSourcesSet.Add(newDataSource); db.SaveChanges(); Console.WriteLine("Source de données après ajout :"); foreach (var dataSource in db.DataSourcesSet) { - Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); } newDataSource.Type = "Garmin"; @@ -457,7 +844,7 @@ class Program Console.WriteLine("Source de données après modification :"); foreach (var dataSource in db.DataSourcesSet) { - Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); } db.DataSourcesSet.Remove(newDataSource); @@ -466,7 +853,7 @@ class Program Console.WriteLine("Source de données après suppression :"); foreach (var dataSource in db.DataSourcesSet) { - Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}"); } } diff --git a/src/Tests/ConsoleTestEntities/uca.HeartTrack.db b/src/Tests/ConsoleTestEntities/uca.HeartTrack.db index 25234ed7daad078958a78f27fdfe71ac542fc053..0065538f1912775182326dd3ea03bbc49fb377ec 100644 GIT binary patch delta 192 zcmZp8z|`=7X+oCRUk1Lb{A+m@@dR+qC(kGVVSU!$C?CVc%f>9v z7+jKAl384mnam}?%B;%hmtT^ZmYEC`%g^KDWdSPiNKGs%2}&$U<>F&zR%CQZEJ+N` nFD*(=<>F>ymS%J;$;e3sO7bu=%Q8A9mt>Y@mQ?aA3P=C|6u&pm delta 186 zcmZp8z|`=7X+oCR9|pdw{A+m@@dR+qrQ8M`=tJvmS+yWvjM#iQVo8QSZ3P4z&^*74Lu<^1n%QFU-B$i|r zmt-ch39vG&GWzA0WTs^%1I6<5*mzlh3OrI1i%NnLOH$eRn3)wBT@p(YgY!#^l2h5Z gnV6*+9ZNEDQh|~@jLfo(j>#pNWtk