public async Task TestSuccessfulPost() { using (var context = new MyMovieTrackerContext(options)) { MediaController mediaController = new MediaController(context); MediaController.MediaDTO dto = new MediaController.MediaDTO() { media_id = 335983, media_type = "movie" }; ActionResult <Media> result = await mediaController.PostMedia(dto); Assert.IsNotNull(result); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(CreatedAtActionResult)); } }
public async Task TestPostConflict() { using (var context = new MyMovieTrackerContext(options)) { MediaController mediaController = new MediaController(context); MediaController.MediaDTO dto = new MediaController.MediaDTO() { media_id = 1399, media_type = "tv" }; try { ActionResult <Media> result = await mediaController.PostMedia(dto); Assert.Fail(); } catch (ArgumentException e) { Console.WriteLine(e.Message); } } }