Example #1
0
        public async Task TestFavouritesPost()
        {
            using (var context = new MyMovieTrackerContext(options)) {
                UserFavouritesController favController = new UserFavouritesController(context);

                UserFavourites fav = new UserFavourites()
                {
                    UserId    = 8,
                    MediaType = "tv",
                    MediaId   = 100
                };

                ActionResult <UserFavourites> result = await favController.PostUserFavourites(fav);

                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Result);
                Assert.IsInstanceOfType(result.Result, typeof(CreatedAtActionResult));
            }
        }
Example #2
0
        public async Task TestFavouritesPostConflict()
        {
            using (var context = new MyMovieTrackerContext(options)) {
                UserFavouritesController favController = new UserFavouritesController(context);

                UserFavourites fav = new UserFavourites()
                {
                    UserId    = 5,
                    MediaType = "tv",
                    MediaId   = 123
                };

                try {
                    ActionResult <UserFavourites> result = await favController.PostUserFavourites(fav);

                    Assert.Fail();
                } catch (ArgumentException e) {
                    Console.WriteLine(e.Message);
                }
            }
        }