public void A_AddWorkoutTest() { var categories = workoutCategoryRepository.GetCategories().FirstOrDefault(); var users = userRepository.GetAll().FirstOrDefault(); workout_collection wc = new workout_collection() { workout_id = 0, workout_title = "TestRepositoryWorkout", workout_note = "TestRepositoryNote", category_id = categories.category_id, calories_burn_per_min = 50, user_id = users.user_id, user = users, workout_category = categories, workout_active = null }; var usrList = wcRepository.FindBy(x => x.workout_title.Equals(wc.workout_title, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (usrList != null) { } else { wcRepository.AddWorkout(wc); _context.SaveChanges(); var result = wcRepository.FindBy(x => x.workout_title.Equals(wc.workout_title, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); Assert.AreNotEqual(0, result.workout_id); } }
public void CreateWorkout(workout_collection wc) { workoutCollectionRepository.AddWorkout(wc); unitOfWork.Commit(); }