public void InsertTest() { // Arrange WorkoutTypeController controllerwt = new WorkoutTypeController(); // Act List <WorkoutType> loadAllWt = controllerwt.Get() as List <WorkoutType>; //grab first result WorkoutType wt = loadAllWt[0]; // Arrange UserController controlleru = new UserController(); // Act List <User> loadAllU = controlleru.Get() as List <User>; //grab first result User u = loadAllU[0]; Workout w = new Workout { WorkoutType = wt, StartTime = System.DateTime.Now, EndTime = new System.DateTime(2020, 11, 18), UserId = u.Id }; // Arrange WorkoutController controller = new WorkoutController(); // Act int result = controller.Post(w); // Assert Assert.IsTrue(result > 0); }
public void UpdateTest() { // Arrange WorkoutController controller = new WorkoutController(); // Act List <Workout> loadAll = controller.Get() as List <Workout>; //grab first result Workout w = loadAll[0]; w.EndTime = System.DateTime.Now; int results = controller.Post(w); Assert.IsTrue(results > 0); }
public void AddNewWorkout_ValidWorkout_ReturnsTrue() { IHttpActionResult actionResult = _categoryController.Get(); var contentResult = actionResult as OkNegotiatedContentResult <IOrderedEnumerable <CategoryDTO> >; Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); var category = contentResult.Content.FirstOrDefault(); var workout = new WorkoutDTO() { WorkoutTitle = "Workout Title", WorkoutNote = "Workout Note", CategoryId = category.CategoryId }; IHttpActionResult postActionResult = _workoutController.Post(workout); var postContentResult = postActionResult as OkNegotiatedContentResult <bool>; Assert.IsNotNull(postActionResult); Assert.IsNotNull(postContentResult.Content); Assert.IsTrue(postContentResult.Content); }