Update and pass all the tests
continuous-integration/drone/push Build is passing Details

WORK-KMO2
Antoine PEREDERII 1 year ago
parent 26734676a9
commit 62cc38f429

@ -21,7 +21,9 @@ public class AthleteEntityTests (DatabaseFixture fixture) : IClassFixture<Databa
Weight = 75.5f,
Password = "password",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
ProfilPicture = "profile.jpg",
DataSourceId = 1
};
@ -54,7 +56,9 @@ public class AthleteEntityTests (DatabaseFixture fixture) : IClassFixture<Databa
Weight = 60.0f,
Password = "password123",
DateOfBirth = new DateOnly(1995, 5, 10),
IsCoach = false
IsCoach = false,
DataSourceId = 2,
ProfilPicture = "profile.jpg"
};
using (var context = new TrainingStubbedContext(fixture._options))
@ -94,7 +98,8 @@ public class AthleteEntityTests (DatabaseFixture fixture) : IClassFixture<Databa
Weight = 70.0f,
Password = "testpassword",
DateOfBirth = new DateOnly(1985, 10, 20),
IsCoach = false
IsCoach = false,
DataSourceId = 3
};
using (var context = new TrainingStubbedContext(fixture._options))
@ -132,7 +137,8 @@ public class AthleteEntityTests (DatabaseFixture fixture) : IClassFixture<Databa
Weight = 75.5f,
Password = "password",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
using (var context = new TrainingStubbedContext(fixture._options))

@ -21,7 +21,8 @@ public class FriendshipEntityTests (DatabaseFixture fixture) : IClassFixture<Dat
Weight = 70.0f,
Password = "followerpassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var following = new AthleteEntity
@ -36,7 +37,7 @@ public class FriendshipEntityTests (DatabaseFixture fixture) : IClassFixture<Dat
Password = "followingpassword",
DateOfBirth = new DateOnly(1995, 5, 10),
IsCoach = false,
Followers = (ICollection<FriendshipEntity>)follower
DataSourceId = 2
};
var friendship = new FriendshipEntity
@ -45,23 +46,31 @@ public class FriendshipEntityTests (DatabaseFixture fixture) : IClassFixture<Dat
Following = following,
StartDate = DateTime.Now
};
//Cast impossible entre Entities.AthleteEntity & System.Collections.Generic.ICollection ; Idem pour Update et Delete mais pas modif vu que ca ne fonctionne pas
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.AthletesSet.Add(follower);
context.AthletesSet.Add(following);
var follow = context.AthletesSet.FirstOrDefault(a => a.Username == "following_user1");
follow.Followings = (ICollection<FriendshipEntity>)following;
context.SaveChanges();
}
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedAth1 = context.AthletesSet.FirstOrDefault(a => a.Username == "following_user1");
var savedAth2 = context.AthletesSet.FirstOrDefault(a => a.Username == "follower_user1");
Assert.Equal(savedAth2, friendship.Follower);
Assert.Equal(savedAth1, friendship.Following);
context.Attach(friendship); // Attachez l'amitié au contexte
context.SaveChanges();
}
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedFriendship = context.AthletesSet.Include(a => a.Followers).Include(a => a.Followings).FirstOrDefault(a => a.Username == "follower_user1").Followers.FirstOrDefault(f => f.FollowerId == follower.IdAthlete && f.FollowingId == following.IdAthlete);
Assert.NotNull(savedFriendship);
if (savedFriendship != null)
{
Assert.Equal(follower.IdAthlete, savedFriendship.FollowerId);
Assert.Equal(following.IdAthlete, savedFriendship.FollowingId);
}
}
}

@ -122,7 +122,7 @@ public class HeartRateEntityTests (DatabaseFixture fixture) : IClassFixture<Data
Date = new DateOnly(2024, 3, 15),
StartTime = new TimeOnly(9, 0),
EndTime = new TimeOnly(10, 0),
EffortFelt = 7,
EffortFelt = 5,
Variability = 0.5f,
Variance = 0.2f,
StandardDeviation = 0.3f,
@ -143,7 +143,7 @@ public class HeartRateEntityTests (DatabaseFixture fixture) : IClassFixture<Data
Bpm = 150,
Longitude = 45.12345f,
Latitude = 35.6789f,
Activity = activity
ActivityId = 1
};
using (var context = new TrainingStubbedContext(fixture._options))
@ -156,10 +156,20 @@ public class HeartRateEntityTests (DatabaseFixture fixture) : IClassFixture<Data
// Ne veut pas passer, si quelqu'un sait pourquoi ... Erreur : System.ArgumentNullException : Value cannot be null. (Parameter 'entity')
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedHeartRate = context.HeartRatesSet.FirstOrDefault(h => h.Altitude == 105.0);
var savedActivity = context.ActivitiesSet.FirstOrDefault(a => a.Type == "Run" && a.EffortFelt == 7 && a.Average == 0.4f);
var savedHeartRate = context.HeartRatesSet.First(h => h.Altitude == 105.0);
var savedActivity = context.ActivitiesSet.First(a => a.Type == "Run");
Assert.NotNull(savedHeartRate);
if (savedHeartRate != null)
{
context.HeartRatesSet.Remove(savedHeartRate);
}
Assert.NotNull(savedActivity);
if (savedActivity != null)
{
context.ActivitiesSet.Remove(savedActivity);
}
context.SaveChanges();
}

@ -21,7 +21,8 @@ public class NotificationEntityTests (DatabaseFixture fixture) : IClassFixture<D
Weight = 70.0f,
Password = "senderpassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var notification = new NotificationEntity
@ -63,7 +64,8 @@ public class NotificationEntityTests (DatabaseFixture fixture) : IClassFixture<D
Weight = 70.0f,
Password = "senderpassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var notification = new NotificationEntity
@ -112,7 +114,8 @@ public class NotificationEntityTests (DatabaseFixture fixture) : IClassFixture<D
Weight = 70.0f,
Password = "senderpassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 3
};
var notification = new NotificationEntity
@ -160,7 +163,8 @@ public class NotificationEntityTests (DatabaseFixture fixture) : IClassFixture<D
Weight = 70.0f,
Password = "senderpassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 3
};
var notification = new NotificationEntity

@ -21,7 +21,8 @@ public class StatisticEntityTests (DatabaseFixture fixture) : IClassFixture<Data
Weight = 70.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var statistic = new StatisticEntity
@ -64,7 +65,8 @@ public class StatisticEntityTests (DatabaseFixture fixture) : IClassFixture<Data
Weight = 70.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var statistic = new StatisticEntity
@ -114,7 +116,8 @@ public class StatisticEntityTests (DatabaseFixture fixture) : IClassFixture<Data
Weight = 70.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var statistic = new StatisticEntity
@ -164,7 +167,8 @@ public class StatisticEntityTests (DatabaseFixture fixture) : IClassFixture<Data
Weight = 70.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 1, 1),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var statistic = new StatisticEntity

@ -21,7 +21,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 75.0f,
Password = "coachpassword",
DateOfBirth = new DateOnly(1985, 5, 15),
IsCoach = true
IsCoach = true,
DataSourceId = 1
};
var athlete = new AthleteEntity
@ -35,7 +36,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 60.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 3, 20),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var training = new TrainingEntity
@ -80,7 +82,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 75.0f,
Password = "coachpassword",
DateOfBirth = new DateOnly(1985, 5, 15),
IsCoach = true
IsCoach = true,
DataSourceId = 1
};
var athlete = new AthleteEntity
@ -94,7 +97,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 60.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 3, 20),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var training = new TrainingEntity
@ -146,7 +150,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 75.0f,
Password = "coachpassword",
DateOfBirth = new DateOnly(1985, 5, 15),
IsCoach = true
IsCoach = true,
DataSourceId = 1
};
var athlete = new AthleteEntity
@ -160,7 +165,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 60.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 3, 20),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var training = new TrainingEntity
@ -211,7 +217,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 75.0f,
Password = "coachpassword",
DateOfBirth = new DateOnly(1985, 5, 15),
IsCoach = true
IsCoach = true,
DataSourceId = 1
};
var athlete = new AthleteEntity
@ -225,7 +232,8 @@ public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
Weight = 60.0f,
Password = "athletepassword",
DateOfBirth = new DateOnly(1990, 3, 20),
IsCoach = false
IsCoach = false,
DataSourceId = 1
};
var training = new TrainingEntity

Loading…
Cancel
Save