public void A_CreateWorkoutTest() { var categories = workoutCategoryService.GetWorkoutCategories().FirstOrDefault(); var users = userService.GetUsers().FirstOrDefault(); workout_collection wc = new workout_collection() { workout_id = 0, workout_title = "TestServiceWorkout", workout_note = "TestServiceNote", category_id = categories.category_id, calories_burn_per_min = 50, user_id = users.user_id, user = users, workout_category = categories, workout_active = null }; var wrList = workoutCollectionService.GetWorkouts().Where(x => x.workout_title.Equals(wc.workout_title, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (wrList != null) { } else { workoutCollectionService.CreateWorkout(wc); var result = workoutCollectionRepository.FindBy(x => x.workout_title.Equals(wc.workout_title, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); Assert.AreNotEqual(0, result.workout_id); } }
public void G_GetWorkoutApiTest() { WorkoutCollection result; var wc = workoutService.GetWorkouts().Where(w => w.workout_title.Equals("TestApiWorkout", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); var controller = new WorkoutTrackerController(workoutService, categoryService, _logManager); var input = Helper.CastObject <WorkoutCollection>(wc); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); controller.Request.Headers.Add("Accept", "application/json"); var response = controller.GetWorkout(input); result = response.Content.ReadAsAsync <WorkoutCollection>().Result; Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.AreNotEqual(null, result); response.Dispose(); }