Tests somes Entities

WORK-WebAPI
Antoine PEREDERII 1 year ago
parent 4362499396
commit 777326829c

@ -7,6 +7,14 @@ public class LibraryContext : DbContext
{ {
public DbSet<AthleteEntity> AthletesSet { get; set; } public DbSet<AthleteEntity> AthletesSet { get; set; }
public DbSet<ActivityEntity> ActivitiesSet { get; set; }
public DbSet<DataSourceEntity> DataSourcesSet { get; set; }
public DbSet<HeartRateEntity> HeartRatesSet { get; set; }
public DbSet<NotificationEntity> NotificationsSet { get; set; }
public DbSet<StatisticEntity> StatisticsSet { get; set; }
public DbSet<TrainingEntity> TrainingsSet { get; set; }
public LibraryContext() public LibraryContext()
:base() :base()
{ } { }

@ -10,9 +10,20 @@ public class ActivityEntity
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdActivity { get; set; } public int IdActivity { get; set; }
[Required]
[MaxLength(100)]
public required string Type { get; set; } public required string Type { get; set; }
[Required(ErrorMessage = "Activity Date is required")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime Date { get; set; } public DateTime Date { get; set; }
[Required(ErrorMessage = "Start Activity Hour is required")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public DateTime StartTime { get; set; } public DateTime StartTime { get; set; }
[Required(ErrorMessage = "End Activity Hour is required")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public DateTime EndTime { get; set; } public DateTime EndTime { get; set; }
public int EffortFelt { get; set; } public int EffortFelt { get; set; }
public float Variability { get; set; } public float Variability { get; set; }

@ -17,9 +17,11 @@ public class AthleteEntity
public required string LastName { get; set; } public required string LastName { get; set; }
[MaxLength(150)] [MaxLength(150)]
public required string FirstName { get; set; } public required string FirstName { get; set; }
[MaxLength(100)]
public required string Email { get; set; } public required string Email { get; set; }
[MaxLength(1)]
public required string Sexe { get; set; } public required string Sexe { get; set; }
public float Lenght { get; set; } public double Lenght { get; set; }
public float Weight { get; set; } public float Weight { get; set; }
public required string Password { get; set; } public required string Password { get; set; }
public DateTime DateOfBirth { get; set; } public DateTime DateOfBirth { get; set; }

@ -9,7 +9,9 @@ public class DataSourceEntity
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdSource { get; set; } public int IdSource { get; set; }
[MaxLength(100)]
public required string Type { get; set; } public required string Type { get; set; }
[MaxLength(100)]
public required string Modele { get; set; } public required string Modele { get; set; }
public float Precision { get; set; } public float Precision { get; set; }
} }

@ -10,6 +10,9 @@ public class HeartRateEntity
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdHeartRate { get; set; } public int IdHeartRate { get; set; }
public double Altitude { get; set; } public double Altitude { get; set; }
[Required(ErrorMessage = "HeartRate Time is required")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public DateTime Time { get; set; } public DateTime Time { get; set; }
public float Temperature { get; set; } public float Temperature { get; set; }
public int Bpm { get; set; } public int Bpm { get; set; }

@ -9,8 +9,14 @@ public class NotificationEntity
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdNotif { get; set; } public int IdNotif { get; set; }
public required string Message { 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")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy - HH}", ApplyFormatInEditMode = true)]
public DateTime Date { get; set; } public DateTime Date { get; set; }
public required bool Statut { get; set; } public bool Statut { get; set; }
[MaxLength(100)]
public required string Urgence { get; set; } public required string Urgence { get; set; }
} }

@ -13,5 +13,8 @@ public class StatisticEntity
public double AverageHeartRate { get; set; } public double AverageHeartRate { get; set; }
public double MaximumHeartRate { get; set; } public double MaximumHeartRate { get; set; }
public double AverageCaloriesBurned { get; set; } public double AverageCaloriesBurned { get; set; }
[Required(ErrorMessage = "Satistic Date is required")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime Date { get; set; } public DateTime Date { get; set; }
} }

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.CompilerServices;
namespace Entities; namespace Entities;
@ -10,6 +11,9 @@ public class TrainingEntity
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdTraining { get; set; } public int IdTraining { get; set; }
[Required(ErrorMessage = "Training Date is required")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime Date { get; set; } public DateTime Date { get; set; }
[MaxLength(300)] [MaxLength(300)]
public string? Description { get; set; } public string? Description { get; set; }

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib; namespace StubbedContextLib;
public class AthleteStubbedContext : LibraryContext public class AthleteStubbedContext : ActivityStubbedContext
{ {
public AthleteStubbedContext() public AthleteStubbedContext()
:base() :base()

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib; namespace StubbedContextLib;
public class DataSourceStubbedContext : LibraryContext public class DataSourceStubbedContext : AthleteStubbedContext
{ {
public DataSourceStubbedContext() public DataSourceStubbedContext()
:base() :base()

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib; namespace StubbedContextLib;
public class HeartRateStubbedContext : LibraryContext public class HeartRateStubbedContext : DataSourceStubbedContext
{ {
public HeartRateStubbedContext() public HeartRateStubbedContext()
:base() :base()

@ -1,147 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StubbedContextLib;
#nullable disable
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(AthleteStubbedContext))]
[Migration("20240216134447_MyMirgations")]
partial class MyMirgations
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Property<int>("IdAthlete")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("DateOfBirth")
.HasColumnType("TEXT");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("TEXT");
b.Property<bool>("IsCoach")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Lenght")
.HasColumnType("REAL");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Sexe")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdAthlete");
b.ToTable("Athlete");
b.HasData(
new
{
IdAthlete = 1,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "john.doe@example.com",
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Lenght = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
Weight = 75f
},
new
{
IdAthlete = 2,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "jane.smith@example.com",
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Lenght = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
Weight = 60f
},
new
{
IdAthlete = 3,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "paul.martin@example.com",
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Lenght = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
Weight = 68f
},
new
{
IdAthlete = 4,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "anna.brown@example.com",
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Lenght = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
Weight = 58f
},
new
{
IdAthlete = 5,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "bruce.lee@example.com",
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Lenght = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
Weight = 90f
});
});
#pragma warning restore 612, 618
}
}
}

@ -1,58 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class MyMirgations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Athlete",
columns: table => new
{
IdAthlete = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Username = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
LastName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
FirstName = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
Email = table.Column<string>(type: "TEXT", nullable: false),
Sexe = table.Column<string>(type: "TEXT", nullable: false),
Lenght = table.Column<double>(type: "REAL", nullable: false),
Weight = table.Column<float>(type: "REAL", nullable: false),
Password = table.Column<string>(type: "TEXT", nullable: false),
DateOfBirth = table.Column<DateTime>(type: "TEXT", nullable: false),
IsCoach = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Athlete", x => x.IdAthlete);
});
migrationBuilder.InsertData(
table: "Athlete",
columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Lenght", "Password", "Sexe", "Username", "Weight" },
values: new object[,]
{
{ 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f },
{ 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "jane.smith@example.com", "Jane", false, "Smith", 1.6499999999999999, "secure456", "F", "Smith", 60f },
{ 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "paul.martin@example.com", "Paul", true, "Martin", 1.75, "super789", "M", "Martin", 68f },
{ 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "anna.brown@example.com", "Anna", false, "Brown", 1.7, "test000", "F", "Brown", 58f },
{ 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "bruce.lee@example.com", "Bruce", false, "Lee", 2.0, "hello321", "M", "Lee", 90f }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Athlete");
}
}
}

@ -0,0 +1,678 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StubbedContextLib;
#nullable disable
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(TrainingStubbedContext))]
[Migration("20240219105500_MyMigrations")]
partial class MyMigrations
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.Property<int>("IdActivity")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<float>("Average")
.HasColumnType("REAL");
b.Property<float>("AverageTemperature")
.HasColumnType("REAL");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("EffortFelt")
.HasColumnType("INTEGER");
b.Property<DateTime>("EndTime")
.HasColumnType("TEXT");
b.Property<bool>("HasAutoPause")
.HasColumnType("INTEGER");
b.Property<int>("Maximum")
.HasColumnType("INTEGER");
b.Property<int>("Minimum")
.HasColumnType("INTEGER");
b.Property<float>("StandardDeviation")
.HasColumnType("REAL");
b.Property<DateTime>("StartTime")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Variability")
.HasColumnType("REAL");
b.Property<float>("Variance")
.HasColumnType("REAL");
b.HasKey("IdActivity");
b.ToTable("Activity");
b.HasData(
new
{
IdActivity = 1,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Running",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 2,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Cycling",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 3,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Swimming",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 4,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Walking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 5,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Hiking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 6,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Climbing",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 7,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Yoga",
Variability = 0.5f,
Variance = 0.5f
});
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Property<int>("IdAthlete")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("DateOfBirth")
.HasColumnType("TEXT");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("TEXT");
b.Property<bool>("IsCoach")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Lenght")
.HasColumnType("REAL");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Sexe")
.IsRequired()
.HasMaxLength(1)
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdAthlete");
b.ToTable("Athlete");
b.HasData(
new
{
IdAthlete = 1,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "john.doe@example.com",
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Lenght = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
Weight = 75f
},
new
{
IdAthlete = 2,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "jane.smith@example.com",
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Lenght = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
Weight = 60f
},
new
{
IdAthlete = 3,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "paul.martin@example.com",
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Lenght = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
Weight = 68f
},
new
{
IdAthlete = 4,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "anna.brown@example.com",
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Lenght = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
Weight = 58f
},
new
{
IdAthlete = 5,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "bruce.lee@example.com",
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Lenght = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
Weight = 90f
});
});
modelBuilder.Entity("Entities.DataSourceEntity", b =>
{
b.Property<int>("IdSource")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Modele")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Precision")
.HasColumnType("REAL");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdSource");
b.ToTable("DataSource");
b.HasData(
new
{
IdSource = 1,
Modele = "Garmin",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 2,
Modele = "Polar",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 3,
Modele = "Suunto",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 4,
Modele = "Fitbit",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 5,
Modele = "Apple Watch",
Precision = 0.5f,
Type = "Smartwatch"
});
});
modelBuilder.Entity("Entities.HeartRateEntity", b =>
{
b.Property<int>("IdHeartRate")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double>("Altitude")
.HasColumnType("REAL");
b.Property<int>("Bpm")
.HasColumnType("INTEGER");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.Property<float>("Temperature")
.HasColumnType("REAL");
b.Property<DateTime>("Time")
.HasColumnType("TEXT");
b.HasKey("IdHeartRate");
b.ToTable("HeartRate");
b.HasData(
new
{
IdHeartRate = 1,
Altitude = 0.0,
Bpm = 60,
Latitude = 66f,
Longitude = 35f,
Temperature = 20f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 2,
Altitude = 10.0,
Bpm = 65,
Latitude = 67f,
Longitude = 35f,
Temperature = 20.5f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 3,
Altitude = 11.0,
Bpm = 71,
Latitude = 66f,
Longitude = 36f,
Temperature = 20f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 4,
Altitude = 12.0,
Bpm = 75,
Latitude = 67f,
Longitude = 36f,
Temperature = 20.5f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 5,
Altitude = 13.0,
Bpm = 80,
Latitude = 66f,
Longitude = 37f,
Temperature = 20f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
});
});
modelBuilder.Entity("Entities.NotificationEntity", b =>
{
b.Property<int>("IdNotif")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<bool>("Statut")
.HasColumnType("INTEGER");
b.Property<string>("Urgence")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdNotif");
b.ToTable("Notification");
b.HasData(
new
{
IdNotif = 1,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new activity to check",
Statut = true,
Urgence = "A"
},
new
{
IdNotif = 2,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new athlete to check",
Statut = false,
Urgence = "3"
},
new
{
IdNotif = 3,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new heart rate to check",
Statut = true,
Urgence = "2"
},
new
{
IdNotif = 4,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new data source to check",
Statut = false,
Urgence = "1"
},
new
{
IdNotif = 5,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new notification to check",
Statut = true,
Urgence = "3"
});
});
modelBuilder.Entity("Entities.StatisticEntity", b =>
{
b.Property<int>("IdStatistic")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double>("AverageCaloriesBurned")
.HasColumnType("REAL");
b.Property<double>("AverageHeartRate")
.HasColumnType("REAL");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<double>("MaximumHeartRate")
.HasColumnType("REAL");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdStatistic");
b.ToTable("Statistic");
b.HasData(
new
{
IdStatistic = 1,
AverageCaloriesBurned = 500.0,
AverageHeartRate = 120.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 180.0,
Weight = 75f
},
new
{
IdStatistic = 2,
AverageCaloriesBurned = 600.0,
AverageHeartRate = 130.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 190.0,
Weight = 60f
},
new
{
IdStatistic = 3,
AverageCaloriesBurned = 550.0,
AverageHeartRate = 125.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 185.0,
Weight = 68f
},
new
{
IdStatistic = 4,
AverageCaloriesBurned = 650.0,
AverageHeartRate = 135.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 195.0,
Weight = 58f
},
new
{
IdStatistic = 5,
AverageCaloriesBurned = 450.0,
AverageHeartRate = 110.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 170.0,
Weight = 90f
});
});
modelBuilder.Entity("Entities.TrainingEntity", b =>
{
b.Property<int>("IdTraining")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("FeedBack")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.HasKey("IdTraining");
b.ToTable("Training");
b.HasData(
new
{
IdTraining = 1,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 2,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 3,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 4,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 5,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
});
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,258 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class MyMigrations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Activity",
columns: table => new
{
IdActivity = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
StartTime = table.Column<DateTime>(type: "TEXT", nullable: false),
EndTime = table.Column<DateTime>(type: "TEXT", nullable: false),
EffortFelt = table.Column<int>(type: "INTEGER", nullable: false),
Variability = table.Column<float>(type: "REAL", nullable: false),
Variance = table.Column<float>(type: "REAL", nullable: false),
StandardDeviation = table.Column<float>(type: "REAL", nullable: false),
Average = table.Column<float>(type: "REAL", nullable: false),
Maximum = table.Column<int>(type: "INTEGER", nullable: false),
Minimum = table.Column<int>(type: "INTEGER", nullable: false),
AverageTemperature = table.Column<float>(type: "REAL", nullable: false),
HasAutoPause = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Activity", x => x.IdActivity);
});
migrationBuilder.CreateTable(
name: "Athlete",
columns: table => new
{
IdAthlete = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Username = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
LastName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
FirstName = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
Email = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Sexe = table.Column<string>(type: "TEXT", maxLength: 1, nullable: false),
Lenght = table.Column<double>(type: "REAL", nullable: false),
Weight = table.Column<float>(type: "REAL", nullable: false),
Password = table.Column<string>(type: "TEXT", nullable: false),
DateOfBirth = table.Column<DateTime>(type: "TEXT", nullable: false),
IsCoach = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Athlete", x => x.IdAthlete);
});
migrationBuilder.CreateTable(
name: "DataSource",
columns: table => new
{
IdSource = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Modele = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Precision = table.Column<float>(type: "REAL", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DataSource", x => x.IdSource);
});
migrationBuilder.CreateTable(
name: "HeartRate",
columns: table => new
{
IdHeartRate = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Altitude = table.Column<double>(type: "REAL", nullable: false),
Time = table.Column<DateTime>(type: "TEXT", nullable: false),
Temperature = table.Column<float>(type: "REAL", nullable: false),
Bpm = table.Column<int>(type: "INTEGER", nullable: false),
Longitude = table.Column<float>(type: "REAL", nullable: false),
Latitude = table.Column<float>(type: "REAL", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HeartRate", x => x.IdHeartRate);
});
migrationBuilder.CreateTable(
name: "Notification",
columns: table => new
{
IdNotif = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Message = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
Statut = table.Column<bool>(type: "INTEGER", nullable: false),
Urgence = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Notification", x => x.IdNotif);
});
migrationBuilder.CreateTable(
name: "Statistic",
columns: table => new
{
IdStatistic = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Weight = table.Column<float>(type: "REAL", nullable: false),
AverageHeartRate = table.Column<double>(type: "REAL", nullable: false),
MaximumHeartRate = table.Column<double>(type: "REAL", nullable: false),
AverageCaloriesBurned = table.Column<double>(type: "REAL", nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Statistic", x => x.IdStatistic);
});
migrationBuilder.CreateTable(
name: "Training",
columns: table => new
{
IdTraining = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
Latitude = table.Column<float>(type: "REAL", nullable: false),
Longitude = table.Column<float>(type: "REAL", nullable: false),
FeedBack = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Training", x => x.IdTraining);
});
migrationBuilder.InsertData(
table: "Activity",
columns: new[] { "IdActivity", "Average", "AverageTemperature", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" },
values: new object[,]
{
{ 1, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Running", 0.5f, 0.5f },
{ 2, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Cycling", 0.5f, 0.5f },
{ 3, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Swimming", 0.5f, 0.5f },
{ 4, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Walking", 0.5f, 0.5f },
{ 5, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Hiking", 0.5f, 0.5f },
{ 6, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Climbing", 0.5f, 0.5f },
{ 7, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Yoga", 0.5f, 0.5f }
});
migrationBuilder.InsertData(
table: "Athlete",
columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Lenght", "Password", "Sexe", "Username", "Weight" },
values: new object[,]
{
{ 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f },
{ 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "jane.smith@example.com", "Jane", false, "Smith", 1.6499999999999999, "secure456", "F", "Smith", 60f },
{ 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "paul.martin@example.com", "Paul", true, "Martin", 1.75, "super789", "M", "Martin", 68f },
{ 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "anna.brown@example.com", "Anna", false, "Brown", 1.7, "test000", "F", "Brown", 58f },
{ 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "bruce.lee@example.com", "Bruce", false, "Lee", 2.0, "hello321", "M", "Lee", 90f }
});
migrationBuilder.InsertData(
table: "DataSource",
columns: new[] { "IdSource", "Modele", "Precision", "Type" },
values: new object[,]
{
{ 1, "Garmin", 0.5f, "Smartwatch" },
{ 2, "Polar", 0.5f, "Smartwatch" },
{ 3, "Suunto", 0.5f, "Smartwatch" },
{ 4, "Fitbit", 0.5f, "Smartwatch" },
{ 5, "Apple Watch", 0.5f, "Smartwatch" }
});
migrationBuilder.InsertData(
table: "HeartRate",
columns: new[] { "IdHeartRate", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" },
values: new object[,]
{
{ 1, 0.0, 60, 66f, 35f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 2, 10.0, 65, 67f, 35f, 20.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 3, 11.0, 71, 66f, 36f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 4, 12.0, 75, 67f, 36f, 20.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 5, 13.0, 80, 66f, 37f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }
});
migrationBuilder.InsertData(
table: "Notification",
columns: new[] { "IdNotif", "Date", "Message", "Statut", "Urgence" },
values: new object[,]
{
{ 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new activity to check", true, "A" },
{ 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new athlete to check", false, "3" },
{ 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new heart rate to check", true, "2" },
{ 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new data source to check", false, "1" },
{ 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new notification to check", true, "3" }
});
migrationBuilder.InsertData(
table: "Statistic",
columns: new[] { "IdStatistic", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" },
values: new object[,]
{
{ 1, 500.0, 120.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 180.0, 75f },
{ 2, 600.0, 130.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 190.0, 60f },
{ 3, 550.0, 125.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 185.0, 68f },
{ 4, 650.0, 135.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 195.0, 58f },
{ 5, 450.0, 110.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 170.0, 90f }
});
migrationBuilder.InsertData(
table: "Training",
columns: new[] { "IdTraining", "Date", "Description", "FeedBack", "Latitude", "Longitude" },
values: new object[,]
{
{ 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Running", "Good", 48.8566f, 2.3522f },
{ 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Cycling", null, 48.8566f, 2.3522f },
{ 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, "Good", 48.8566f, 2.3522f },
{ 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Running", "Good", 48.8566f, 2.3522f },
{ 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Cycling", null, 48.8566f, 2.3522f }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Activity");
migrationBuilder.DropTable(
name: "Athlete");
migrationBuilder.DropTable(
name: "DataSource");
migrationBuilder.DropTable(
name: "HeartRate");
migrationBuilder.DropTable(
name: "Notification");
migrationBuilder.DropTable(
name: "Statistic");
migrationBuilder.DropTable(
name: "Training");
}
}
}

@ -1,144 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StubbedContextLib;
#nullable disable
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(AthleteStubbedContext))]
partial class AthleteStubbedContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Property<int>("IdAthlete")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("DateOfBirth")
.HasColumnType("TEXT");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("TEXT");
b.Property<bool>("IsCoach")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Lenght")
.HasColumnType("REAL");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Sexe")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdAthlete");
b.ToTable("Athlete");
b.HasData(
new
{
IdAthlete = 1,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "john.doe@example.com",
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Lenght = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
Weight = 75f
},
new
{
IdAthlete = 2,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "jane.smith@example.com",
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Lenght = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
Weight = 60f
},
new
{
IdAthlete = 3,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "paul.martin@example.com",
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Lenght = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
Weight = 68f
},
new
{
IdAthlete = 4,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "anna.brown@example.com",
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Lenght = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
Weight = 58f
},
new
{
IdAthlete = 5,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "bruce.lee@example.com",
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Lenght = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
Weight = 90f
});
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,675 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StubbedContextLib;
#nullable disable
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(TrainingStubbedContext))]
partial class TrainingStubbedContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.Property<int>("IdActivity")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<float>("Average")
.HasColumnType("REAL");
b.Property<float>("AverageTemperature")
.HasColumnType("REAL");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<int>("EffortFelt")
.HasColumnType("INTEGER");
b.Property<DateTime>("EndTime")
.HasColumnType("TEXT");
b.Property<bool>("HasAutoPause")
.HasColumnType("INTEGER");
b.Property<int>("Maximum")
.HasColumnType("INTEGER");
b.Property<int>("Minimum")
.HasColumnType("INTEGER");
b.Property<float>("StandardDeviation")
.HasColumnType("REAL");
b.Property<DateTime>("StartTime")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Variability")
.HasColumnType("REAL");
b.Property<float>("Variance")
.HasColumnType("REAL");
b.HasKey("IdActivity");
b.ToTable("Activity");
b.HasData(
new
{
IdActivity = 1,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Running",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 2,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Cycling",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 3,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Swimming",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 4,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Walking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 5,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Hiking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 6,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Climbing",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 7,
Average = 0.5f,
AverageTemperature = 20f,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
EffortFelt = 5,
EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Type = "Yoga",
Variability = 0.5f,
Variance = 0.5f
});
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Property<int>("IdAthlete")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("DateOfBirth")
.HasColumnType("TEXT");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("TEXT");
b.Property<bool>("IsCoach")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Lenght")
.HasColumnType("REAL");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Sexe")
.IsRequired()
.HasMaxLength(1)
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdAthlete");
b.ToTable("Athlete");
b.HasData(
new
{
IdAthlete = 1,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "john.doe@example.com",
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Lenght = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
Weight = 75f
},
new
{
IdAthlete = 2,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "jane.smith@example.com",
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Lenght = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
Weight = 60f
},
new
{
IdAthlete = 3,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "paul.martin@example.com",
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Lenght = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
Weight = 68f
},
new
{
IdAthlete = 4,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "anna.brown@example.com",
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Lenght = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
Weight = 58f
},
new
{
IdAthlete = 5,
DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Email = "bruce.lee@example.com",
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Lenght = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
Weight = 90f
});
});
modelBuilder.Entity("Entities.DataSourceEntity", b =>
{
b.Property<int>("IdSource")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Modele")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Precision")
.HasColumnType("REAL");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdSource");
b.ToTable("DataSource");
b.HasData(
new
{
IdSource = 1,
Modele = "Garmin",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 2,
Modele = "Polar",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 3,
Modele = "Suunto",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 4,
Modele = "Fitbit",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 5,
Modele = "Apple Watch",
Precision = 0.5f,
Type = "Smartwatch"
});
});
modelBuilder.Entity("Entities.HeartRateEntity", b =>
{
b.Property<int>("IdHeartRate")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double>("Altitude")
.HasColumnType("REAL");
b.Property<int>("Bpm")
.HasColumnType("INTEGER");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.Property<float>("Temperature")
.HasColumnType("REAL");
b.Property<DateTime>("Time")
.HasColumnType("TEXT");
b.HasKey("IdHeartRate");
b.ToTable("HeartRate");
b.HasData(
new
{
IdHeartRate = 1,
Altitude = 0.0,
Bpm = 60,
Latitude = 66f,
Longitude = 35f,
Temperature = 20f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 2,
Altitude = 10.0,
Bpm = 65,
Latitude = 67f,
Longitude = 35f,
Temperature = 20.5f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 3,
Altitude = 11.0,
Bpm = 71,
Latitude = 66f,
Longitude = 36f,
Temperature = 20f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 4,
Altitude = 12.0,
Bpm = 75,
Latitude = 67f,
Longitude = 36f,
Temperature = 20.5f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
IdHeartRate = 5,
Altitude = 13.0,
Bpm = 80,
Latitude = 66f,
Longitude = 37f,
Temperature = 20f,
Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
});
});
modelBuilder.Entity("Entities.NotificationEntity", b =>
{
b.Property<int>("IdNotif")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<bool>("Statut")
.HasColumnType("INTEGER");
b.Property<string>("Urgence")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdNotif");
b.ToTable("Notification");
b.HasData(
new
{
IdNotif = 1,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new activity to check",
Statut = true,
Urgence = "A"
},
new
{
IdNotif = 2,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new athlete to check",
Statut = false,
Urgence = "3"
},
new
{
IdNotif = 3,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new heart rate to check",
Statut = true,
Urgence = "2"
},
new
{
IdNotif = 4,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new data source to check",
Statut = false,
Urgence = "1"
},
new
{
IdNotif = 5,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new notification to check",
Statut = true,
Urgence = "3"
});
});
modelBuilder.Entity("Entities.StatisticEntity", b =>
{
b.Property<int>("IdStatistic")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double>("AverageCaloriesBurned")
.HasColumnType("REAL");
b.Property<double>("AverageHeartRate")
.HasColumnType("REAL");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<double>("MaximumHeartRate")
.HasColumnType("REAL");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdStatistic");
b.ToTable("Statistic");
b.HasData(
new
{
IdStatistic = 1,
AverageCaloriesBurned = 500.0,
AverageHeartRate = 120.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 180.0,
Weight = 75f
},
new
{
IdStatistic = 2,
AverageCaloriesBurned = 600.0,
AverageHeartRate = 130.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 190.0,
Weight = 60f
},
new
{
IdStatistic = 3,
AverageCaloriesBurned = 550.0,
AverageHeartRate = 125.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 185.0,
Weight = 68f
},
new
{
IdStatistic = 4,
AverageCaloriesBurned = 650.0,
AverageHeartRate = 135.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 195.0,
Weight = 58f
},
new
{
IdStatistic = 5,
AverageCaloriesBurned = 450.0,
AverageHeartRate = 110.0,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
MaximumHeartRate = 170.0,
Weight = 90f
});
});
modelBuilder.Entity("Entities.TrainingEntity", b =>
{
b.Property<int>("IdTraining")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("FeedBack")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.HasKey("IdTraining");
b.ToTable("Training");
b.HasData(
new
{
IdTraining = 1,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 2,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 3,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 4,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 5,
Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
});
});
#pragma warning restore 612, 618
}
}
}

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib; namespace StubbedContextLib;
public class NotificationStubbedContext : LibraryContext public class NotificationStubbedContext : HeartRateStubbedContext
{ {
public NotificationStubbedContext() public NotificationStubbedContext()
:base() :base()

@ -0,0 +1,29 @@
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class StatisticStubbedContext : NotificationStubbedContext
{
public StatisticStubbedContext()
:base()
{ }
public StatisticStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<StatisticEntity>().HasData(
new StatisticEntity { IdStatistic = 1, Weight = 75, AverageHeartRate = 120, MaximumHeartRate = 180, AverageCaloriesBurned = 500, Date = new DateTime(12/12/2021) },
new StatisticEntity { IdStatistic = 2, Weight = 60, AverageHeartRate = 130, MaximumHeartRate = 190, AverageCaloriesBurned = 600, Date = new DateTime(11/01/2021) },
new StatisticEntity { IdStatistic = 3, Weight = 68, AverageHeartRate = 125, MaximumHeartRate = 185, AverageCaloriesBurned = 550, Date = new DateTime(30/12/2022) },
new StatisticEntity { IdStatistic = 4, Weight = 58, AverageHeartRate = 135, MaximumHeartRate = 195, AverageCaloriesBurned = 650, Date = new DateTime(20/02/2023) },
new StatisticEntity { IdStatistic = 5, Weight = 90, AverageHeartRate = 110, MaximumHeartRate = 170, AverageCaloriesBurned = 450, Date = new DateTime(10/01/2024) }
);
}
}

@ -0,0 +1,29 @@
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class TrainingStubbedContext : StatisticStubbedContext
{
public TrainingStubbedContext()
:base()
{ }
public TrainingStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<TrainingEntity>().HasData(
new TrainingEntity { IdTraining = 1, Date = new DateTime(19/02/2024), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 2, Date = new DateTime(20/02/2024), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f },
new TrainingEntity { IdTraining = 3, Date = new DateTime(21/02/2024), Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 4, Date = new DateTime(22/02/2024), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 5, Date = new DateTime(23/02/2024), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f }
);
}
}

@ -9,10 +9,22 @@ class Program
{ {
try { try {
using (LibraryContext db = new AthleteStubbedContext()) using (LibraryContext db = new TrainingStubbedContext())
{ {
AthletesTests(db); AthletesTests(db);
ActivityTests(db);
DataSourceTests(db);
HeartRateTests(db);
NotificationTests(db);
StatisticTests(db);
TrainingTests(db);
// // Test d'ajout, de modification et de suppression // // Test d'ajout, de modification et de suppression
// AddUpdateDeleteOperations(db); // AddUpdateDeleteOperations(db);
@ -31,7 +43,7 @@ class Program
{ {
Console.WriteLine("Accès à tous les athletes :"); Console.WriteLine("Accès à tous les athletes :");
// Affichage des livres // Affichage des athletes
Console.WriteLine("Athletes :"); Console.WriteLine("Athletes :");
Console.WriteLine("---------------------------------"); Console.WriteLine("---------------------------------");
@ -143,6 +155,206 @@ class Program
Console.WriteLine("---------------------------------\n"); Console.WriteLine("---------------------------------\n");
} }
static void ActivityTests(LibraryContext db)
{
Console.WriteLine("Accès à toutes les activités :");
Console.WriteLine("Activités :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet)
{
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é d'id '2' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.IdActivity == 2))
{
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 type 'Running' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => 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 date '01/01/2022' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateTime(01/01/2022)))
{
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("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateTime(01/01/2022) && 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 date '01/01/2022' et de type 'Running' et de StartTime '12:00:00' :");
// 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}");
// }
// Console.WriteLine("---------------------------------\n");
}
static void DataSourceTests(LibraryContext db)
{
Console.WriteLine("Accès à toutes les sources de données :");
Console.WriteLine("Sources de données :");
Console.WriteLine("---------------------------------");
foreach (var dataSource in db.DataSourcesSet)
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la source de données d'id '2' :");
Console.WriteLine("---------------------------------");
foreach (var dataSource in db.DataSourcesSet.Where(d => d.IdSource == 2))
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la source de données de type 'Polar' :");
Console.WriteLine("---------------------------------");
foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Polar"))
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
}
static void HeartRateTests(LibraryContext db)
{
Console.WriteLine("Accès à toutes les fréquences cardiaques :");
Console.WriteLine("Fréquences cardiaques :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet)
{
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'id '2' :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet.Where(h => h.IdHeartRate == 2))
{
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)
{
Console.WriteLine("Accès à toutes les notifications :");
Console.WriteLine("Notifications :");
Console.WriteLine("---------------------------------");
foreach (var notification in db.NotificationsSet)
{
Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la notification d'id '2' :");
Console.WriteLine("---------------------------------");
foreach (var notification in db.NotificationsSet.Where(n => n.IdNotif == 2))
{
Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}");
}
Console.WriteLine("---------------------------------\n");
}
static void StatisticTests(LibraryContext db)
{
Console.WriteLine("Accès à toutes les statistiques :");
Console.WriteLine("Statistiques :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet)
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique d'id '2' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.IdStatistic == 2))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
}
static void TrainingTests(LibraryContext db)
{
Console.WriteLine("Accès à tout les entrainements :");
Console.WriteLine("Entrainements :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet)
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement d'id '2' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.IdTraining == 2))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
}
// /// <summary> // /// <summary>
// /// Test d'ajout, de modification et de suppression de livres. // /// Test d'ajout, de modification et de suppression de livres.
// /// </summary> // /// </summary>

Loading…
Cancel
Save