public async Task CanAdd() { using var context = new DataContext(ContextOptions); var user = await GetUser(context); var exerciseRepo = new ExerciseRepository(context); var countBeforeAdd = await exerciseRepo.GetAllByUserId(user.Id); await AddExercise("Exercise test CanAdd", exerciseRepo, context); var countAfterAdd = await exerciseRepo.GetAllByUserId(user.Id); Assert.AreNotSame(countBeforeAdd, countAfterAdd); }
public async Task CanGetByUserId() { using var context = new DataContext(ContextOptions); var user = await GetUser(context); var exerciseRepo = new ExerciseRepository(context); await AddExercise("Exercise test CanGetByUserId", exerciseRepo, context); var exercises = await exerciseRepo.GetAllByUserId(user.Id); Assert.IsNotEmpty(exercises); }
public async Task CanDelete() { using var context = new DataContext(ContextOptions); var user = await GetUser(context); var exerciseRepo = new ExerciseRepository(context); var exerciseName = "Exercise test CanDelete"; await AddExercise(exerciseName, exerciseRepo, context); var exercise = (await exerciseRepo.GetAllByUserId(user.Id)).FirstOrDefault(x => x.Name == exerciseName); Assert.IsNotNull(exercise); // Delete exercise exerciseRepo.Delete(exercise); await exerciseRepo.SaveAll(); // Check is deleted var exercises = await exerciseRepo.GetAllByUserId(user.Id); Assert.IsFalse(exercises.Any(x => x.Name == exerciseName)); }