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 A_AddUserTest() { user _user = new user() { user_id = 0, user_name = "TestRepositoryUser", password = "******", workout_collection = null }; var usrList = userRepository.FindBy(x => x.user_name.Equals(_user.user_name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (usrList != null) { } else { userRepository.AddUser(_user); _context.SaveChanges(); var result = userRepository.FindBy(x => x.user_name.Equals(_user.user_name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); Assert.AreNotEqual(0, result.user_id); } }
public void A_AddCategoryTest() { workout_category wcat = new workout_category() { category_id = 0, category_name = "TestRepositorycategory", workout_collection = null }; var catList = workoutCategoryRepository.FindBy(x => x.category_name.Equals(wcat.category_name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (catList != null) { } else { workoutCategoryRepository.AddCategory(wcat); _context.SaveChanges(); } var result = workoutCategoryRepository.FindBy(x => x.category_name.Equals(wcat.category_name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); Assert.AreNotEqual(0, result.category_id); }