🚑💥 Tests in memory Entities 14/24
continuous-integration/drone/push Build is failing Details

WORK-KEV
Kevin MONTEIRO 1 year ago
parent 681ab41800
commit bbb66c6059

@ -30,21 +30,20 @@ public class ActivityEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
DataSourceId = 1,
AthleteId = 1
};
/*
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Activities.Add(activity);
context.ActivitiesSet.Add(activity);
context.SaveChanges();
}
using (var context = new TrainingStubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedActivity = context.Activities.First(a => a.Type == "Running");
var savedActivity = context.ActivitiesSet.First(a => a.Type == "Running");
Assert.NotNull(savedActivity);
Assert.Equal("Running", savedActivity.Type );
}*/
}
}
[Fact]
@ -69,28 +68,27 @@ public class ActivityEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
AthleteId = 1
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Activities.Add(activity);
context.ActivitiesSet.Add(activity);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedActivity = context.Activities.First(a => a.Type == "Running");
var savedActivity = context.ActivitiesSet.First(a => a.Type == "Running");
savedActivity.Type = "Walking";
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedActivity = context.Activities.First(a => a.Type == "Walking");
var updatedActivity = context.ActivitiesSet.First(a => a.Type == "Walking");
Assert.NotNull(updatedActivity);
Assert.Equal("Walking", updatedActivity.Type );
Assert.Equal(7, updatedActivity.EffortFelt );
}*/
}
}
[Fact]
@ -115,26 +113,26 @@ public class ActivityEntityTests (DatabaseFixture fixture) : IClassFixture<Datab
AthleteId = 1
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Activities.Add(activity);
context.ActivitiesSet.Add(activity);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedActivity = context.Activities.First(a => a.Type == "Running");
context.Activities.Remove(savedActivity);
var savedActivity = context.ActivitiesSet.First(a => a.Type == "Running");
context.ActivitiesSet.Remove(savedActivity);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedActivity = context.Activities.FirstOrDefault(a => a.Type == "Running");
var deletedActivity = context.ActivitiesSet.FirstOrDefault(a => a.Type == "Running");
Assert.Null(deletedActivity);
}*/
}
}
}

@ -3,8 +3,9 @@ using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
public class AthleteEntityTests
public class AthleteEntityTests (DatabaseFixture fixture) : IClassFixture<DatabaseFixture>
{
[Fact]
public void Add_Athlete_Success()
@ -23,20 +24,20 @@ public class AthleteEntityTests
IsCoach = false
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(athlete);
context.AthletesSet.Add(athlete);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedAthlete = context.Athletes.First(a => a.Username == "john_doe");
var savedAthlete = context.AthletesSet.First(a => a.Username == "john_doe");
Assert.NotNull(savedAthlete);
Assert.Equal("john_doe", savedAthlete.Username);
}*/
}
}
[Fact]
@ -56,28 +57,27 @@ public class AthleteEntityTests
IsCoach = false
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(athlete);
context.AthletesSet.Add(athlete);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedAthlete = context.Athletes.First(a => a.Username == "jane_smith");
var savedAthlete = context.AthletesSet.First(a => a.Username == "jane_smith");
savedAthlete.Username = "jane_doe";
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedAthlete = context.Athletes.First(a => a.Username == "jane_doe");
var updatedAthlete = context.AthletesSet.First(a => a.Username == "jane_doe");
Assert.NotNull(updatedAthlete);
Assert.Equal("jane_doe", updatedAthlete.Username);
Assert.Equal("Smith", updatedAthlete.LastName);
}*/
}
}
[Fact]
@ -97,26 +97,25 @@ public class AthleteEntityTests
IsCoach = false
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(athlete);
context.AthletesSet.Add(athlete);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedAthlete = context.Athletes.First(a => a.Username == "test_user");
context.Athletes.Remove(savedAthlete);
var savedAthlete = context.AthletesSet.First(a => a.Username == "test_user");
context.AthletesSet.Remove(savedAthlete);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedAthlete = context.Athletes.FirstOrDefault(a => a.Username == "test_user");
var deletedAthlete = context.AthletesSet.FirstOrDefault(a => a.Username == "test_user");
Assert.Null(deletedAthlete);
}*/
}
}
}

@ -3,9 +3,9 @@ using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
public class DataSourceEntityTests
public class DataSourceEntityTests (DatabaseFixture fixture) : IClassFixture<DatabaseFixture>
{
[Fact]
public void Add_DataSource_Success()
@ -17,20 +17,19 @@ public class DataSourceEntityTests
Precision = 0.1f
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.DataSources.Add(dataSource);
context.DataSourcesSet.Add(dataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedDataSource = context.DataSources.First(d => d.Type == "GPS");
var savedDataSource = context.DataSourcesSet.First(d => d.Type == "GPS");
Assert.NotNull(savedDataSource);
Assert.Equal("Garmin Forerunner 945", savedDataSource.Model);
}*/
}
}
[Fact]
@ -43,28 +42,27 @@ public class DataSourceEntityTests
Precision = 0.2f
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.DataSources.Add(dataSource);
context.DataSourcesSet.Add(dataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedDataSource = context.DataSources.First(d => d.Type == "Heart Rate Monitor");
var savedDataSource = context.DataSourcesSet.First(d => d.Type == "Heart Rate Monitor");
savedDataSource.Model = "Polar H9";
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedDataSource = context.DataSources.First(d => d.Model == "Polar H9");
var updatedDataSource = context.DataSourcesSet.First(d => d.Model == "Polar H9");
Assert.NotNull(updatedDataSource);
Assert.Equal("Heart Rate Monitor", updatedDataSource.Type);
Assert.Equal(0.2f, updatedDataSource.Precision);
}*/
}
}
[Fact]
@ -77,26 +75,25 @@ public class DataSourceEntityTests
Precision = 0.05f
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.DataSources.Add(dataSource);
context.DataSourcesSet.Add(dataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedDataSource = context.DataSources.First(d => d.Type == "Smartwatch");
context.DataSources.Remove(savedDataSource);
var savedDataSource = context.DataSourcesSet.First(d => d.Type == "Smartwatch");
context.DataSourcesSet.Remove(savedDataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedDataSource = context.DataSources.FirstOrDefault(d => d.Type == "Smartwatch");
var deletedDataSource = context.DataSourcesSet.FirstOrDefault(d => d.Type == "Smartwatch");
Assert.Null(deletedDataSource);
}*/
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Data.Sqlite;
using DbContextLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
@ -7,13 +8,13 @@ namespace UnitTestsEntities;
public class DatabaseFixture : IDisposable
{
private readonly SqliteConnection _connection;
public readonly DbContextOptions<TrainingStubbedContext> _options;
public readonly DbContextOptions<HeartTrackContext> _options;
public DatabaseFixture()
{
_connection = new SqliteConnection("DataSource=:memory:");
_connection.Open();
_options = new DbContextOptionsBuilder<TrainingStubbedContext>()
_options = new DbContextOptionsBuilder<HeartTrackContext>()
.UseSqlite(_connection)
.Options;

@ -3,8 +3,9 @@ using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
public class FriendshipEntityTests
public class FriendshipEntityTests (DatabaseFixture fixture) : IClassFixture<DatabaseFixture>
{
[Fact]
public void Add_Friendship_Success()
@ -42,19 +43,18 @@ public class FriendshipEntityTests
Follower = follower,
Following = following,
StartDate = DateTime.Now
};
};/*
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(follower);
context.Athletes.Add(following);
context.AthletesSet.Add(follower);
context.AthletesSet.Add(following);
context.Friendships.Add(friendship);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedFriendship = context.Friendships.FirstOrDefault();
Assert.NotNull(savedFriendship);
@ -113,27 +113,26 @@ public class FriendshipEntityTests
Follower = follower,
Following = following,
StartDate = DateTime.Now
};
};/*
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(follower);
context.Athletes.Add(following);
context.Athletes.Add(thirdAthlete);
context.AthletesSet.Add(follower);
context.AthletesSet.Add(following);
context.AthletesSet.Add(thirdAthlete);
context.Friendships.Add(friendship);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedFriendship = context.Friendships.FirstOrDefault();
savedFriendship.Follower = thirdAthlete; // Update the follower
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedFriendship = context.Friendships.FirstOrDefault();
Assert.NotNull(updatedFriendship);
@ -144,6 +143,7 @@ public class FriendshipEntityTests
[Fact]
public void Delete_Friendship_Success()
{
// Act
var follower = new AthleteEntity
{
Username = "follower_user",
@ -172,31 +172,29 @@ public class FriendshipEntityTests
IsCoach = false
};
var friendship = new FriendshipEntity
{
Follower = follower,
Following = following,
StartDate = DateTime.Now
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(follower);
context.Athletes.Add(following);
context.Friendships.Add(friendship);
context.AthletesSet.Add(follower);
context.AthletesSet.Add(following);
context.SaveChanges();
var user1 = context.AthletesSet.FirstOrDefault(a => a.IdAthlete == follower.IdAthlete);
var user2 = context.AthletesSet.FirstOrDefault(a => a.IdAthlete == following.IdAthlete);
user1.Followers = user2.IdAthlete;
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedFriendship = context.Friendships.FirstOrDefault();
context.Friendships.Remove(savedFriendship);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedFriendship = context.Friendships.FirstOrDefault();
Assert.Null(deletedFriendship);

@ -3,8 +3,9 @@ using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
public class HeartRateEntityTests
public class HeartRateEntityTests (DatabaseFixture fixture) : IClassFixture<DatabaseFixture>
{
[Fact]
public void Add_HeartRate_Success()
@ -39,21 +40,21 @@ public class HeartRateEntityTests
Activity = activity
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Activities.Add(activity);
context.HeartRates.Add(heartRateEntry);
context.ActivitiesSet.Add(activity);
context.HeartRatesSet.Add(heartRateEntry);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedHeartRate = context.HeartRates.First();
var savedHeartRate = context.HeartRatesSet.First();
Assert.NotNull(savedHeartRate);
Assert.Equal(150, savedHeartRate.Bpm);
}*/
}
}
[Fact]
@ -89,28 +90,27 @@ public class HeartRateEntityTests
Activity = activity
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Activities.Add(activity);
context.HeartRates.Add(heartRateEntry);
context.ActivitiesSet.Add(activity);
context.HeartRatesSet.Add(heartRateEntry);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedHeartRate = context.HeartRates.First();
var savedHeartRate = context.HeartRatesSet.First();
savedHeartRate.Bpm = 160;
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedHeartRate = context.HeartRates.First();
var updatedHeartRate = context.HeartRatesSet.First();
Assert.NotNull(updatedHeartRate);
Assert.Equal(160, updatedHeartRate.Bpm);
}*/
}
}
[Fact]
@ -146,27 +146,26 @@ public class HeartRateEntityTests
Activity = activity
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Activities.Add(activity);
context.HeartRates.Add(heartRateEntry);
context.ActivitiesSet.Add(activity);
context.HeartRatesSet.Add(heartRateEntry);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedHeartRate = context.HeartRates.First();
context.HeartRates.Remove(savedHeartRate);
var savedHeartRate = context.HeartRatesSet.First();
context.HeartRatesSet.Remove(savedHeartRate);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedHeartRate = context.HeartRates.FirstOrDefault();
var deletedHeartRate = context.HeartRatesSet.FirstOrDefault();
Assert.Null(deletedHeartRate);
}*/
}
}
}

@ -3,8 +3,9 @@ using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
public class NotificationEntityTests
public class NotificationEntityTests (DatabaseFixture fixture) : IClassFixture<DatabaseFixture>
{
[Fact]
public void Add_Notification_Success()
@ -32,21 +33,20 @@ public class NotificationEntityTests
Sender = sender
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(sender);
context.Notifications.Add(notification);
context.AthletesSet.Add(sender);
context.NotificationsSet.Add(notification);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedNotification = context.Notifications.First();
var savedNotification = context.NotificationsSet.First();
Assert.NotNull(savedNotification);
Assert.Equal("Test notification", savedNotification.Message);
}*/
}
}
[Fact]
@ -75,28 +75,27 @@ public class NotificationEntityTests
Sender = sender
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(sender);
context.Notifications.Add(notification);
context.AthletesSet.Add(sender);
context.NotificationsSet.Add(notification);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedNotification = context.Notifications.First();
var savedNotification = context.NotificationsSet.First();
savedNotification.Message = "Updated message";
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedNotification = context.Notifications.First();
var updatedNotification = context.NotificationsSet.First();
Assert.NotNull(updatedNotification);
Assert.Equal("Updated message", updatedNotification.Message);
}*/
}
}
[Fact]
@ -125,27 +124,26 @@ public class NotificationEntityTests
Sender = sender
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(sender);
context.Notifications.Add(notification);
context.AthletesSet.Add(sender);
context.NotificationsSet.Add(notification);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedNotification = context.Notifications.First();
context.Notifications.Remove(savedNotification);
var savedNotification = context.NotificationsSet.First();
context.NotificationsSet.Remove(savedNotification);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedNotification = context.Notifications.FirstOrDefault();
var deletedNotification = context.NotificationsSet.FirstOrDefault();
Assert.Null(deletedNotification);
}*/
}
}
}

@ -3,9 +3,9 @@ using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
public class StatisticEntityTests
public class StatisticEntityTests (DatabaseFixture fixture) : IClassFixture<DatabaseFixture>
{
[Fact]
public void Add_Statistic_Success()
@ -34,21 +34,20 @@ public class StatisticEntityTests
Athlete = athlete
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(athlete);
context.Statistics.Add(statistic);
context.AthletesSet.Add(athlete);
context.StatisticsSet.Add(statistic);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedStatistic = context.Statistics.First();
var savedStatistic = context.StatisticsSet.FirstOrDefault(s => s.AverageHeartRate == 150.0 && s.MaximumHeartRate == 180.0);
Assert.NotNull(savedStatistic);
Assert.Equal(75.0f, savedStatistic.Weight);
}*/
}
}
[Fact]
@ -78,28 +77,27 @@ public class StatisticEntityTests
Athlete = athlete
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(athlete);
context.Statistics.Add(statistic);
context.AthletesSet.Add(athlete);
context.StatisticsSet.Add(statistic);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedStatistic = context.Statistics.First();
var savedStatistic = context.StatisticsSet.First();
savedStatistic.Weight = 80.0f;
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedStatistic = context.Statistics.First();
var updatedStatistic = context.StatisticsSet.First();
Assert.NotNull(updatedStatistic);
Assert.Equal(80.0f, updatedStatistic.Weight);
}*/
}
}
[Fact]
@ -129,27 +127,26 @@ public class StatisticEntityTests
Athlete = athlete
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(athlete);
context.Statistics.Add(statistic);
context.AthletesSet.Add(athlete);
context.StatisticsSet.Add(statistic);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedStatistic = context.Statistics.First();
context.Statistics.Remove(savedStatistic);
var savedStatistic = context.StatisticsSet.FirstOrDefault(s => s.Weight == 75.0 && s.AverageHeartRate == 150.0 && s.MaximumHeartRate == 180.0);
context.StatisticsSet.Remove(savedStatistic);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedStatistic = context.Statistics.FirstOrDefault();
var deletedStatistic = context.StatisticsSet.FirstOrDefault(s => s.Weight == 75.0 && s.AverageHeartRate == 150.0 && s.MaximumHeartRate == 180.0);
Assert.Null(deletedStatistic);
}*/
}
}
}

@ -3,9 +3,9 @@ using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
using StubbedContextLib;
public class TrainingEntityTests
public class TrainingEntityTests (DatabaseFixture fixture) : IClassFixture<DatabaseFixture>
{
[Fact]
public void Add_Training_Success()
@ -49,22 +49,21 @@ public class TrainingEntityTests
Athletes = { athlete }
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(coach);
context.Athletes.Add(athlete);
context.Trainings.Add(training);
context.AthletesSet.Add(coach);
context.AthletesSet.Add(athlete);
context.TrainingsSet.Add(training);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedTraining = context.Trainings.First();
var savedTraining = context.TrainingsSet.First();
Assert.NotNull(savedTraining);
Assert.Equal("Training description", savedTraining.Description);
}*/
}
}
[Fact]
@ -109,29 +108,28 @@ public class TrainingEntityTests
Athletes = { athlete }
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(coach);
context.Athletes.Add(athlete);
context.Trainings.Add(training);
context.AthletesSet.Add(coach);
context.AthletesSet.Add(athlete);
context.TrainingsSet.Add(training);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedTraining = context.Trainings.First();
var savedTraining = context.TrainingsSet.First();
savedTraining.Description = "Updated training description";
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var updatedTraining = context.Trainings.First();
var updatedTraining = context.TrainingsSet.First();
Assert.NotNull(updatedTraining);
Assert.Equal("Updated training description", updatedTraining.Description);
}*/
}
}
[Fact]
@ -176,27 +174,26 @@ public class TrainingEntityTests
Athletes = { athlete }
};
/*
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
context.Database.EnsureCreated();
context.Athletes.Add(coach);
context.Athletes.Add(athlete);
context.Trainings.Add(training);
context.AthletesSet.Add(coach);
context.AthletesSet.Add(athlete);
context.TrainingsSet.Add(training);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var savedTraining = context.Trainings.First();
context.Trainings.Remove(savedTraining);
var savedTraining = context.TrainingsSet.First();
context.TrainingsSet.Remove(savedTraining);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
using (var context = new TrainingStubbedContext(fixture._options))
{
var deletedTraining = context.Trainings.FirstOrDefault();
var deletedTraining = context.TrainingsSet.FirstOrDefault();
Assert.Null(deletedTraining);
}*/
}
}
}

Loading…
Cancel
Save