public void RemoteApiFailure_ReturnException()
        {
            var client = new RemoteApiClient("https://www.example.com", "/does/not/exist/");
            var movieListingService = new MovieListingService(client);

            Assert.ThrowsException <ContentRetrievalException>(() => movieListingService.GetSortedList(), "ContentRetrievalException should occur when incorrect URL is provided");
        }
        public void RemoteApiIncorrectResource_NullReturn()
        {
            var client = new RemoteApiClient(Mother.RemoteApiBaseUrl, "/does/not/exist/");
            var movieListingService = new MovieListingService(client);
            var sortedList          = movieListingService.GetSortedList();

            Assert.IsNull(sortedList, "Empty list should be null");
        }
        public void EmptyList6_NullReturn()
        {
            var client = new LocalStaticClient(string.Empty);
            var movieListingService = new MovieListingService(client);
            var sortedList          = movieListingService.GetSortedList();

            Assert.IsNull(sortedList, "Empty list should be null");
        }
        private void CheckItem(string sampleList, string firstActorName, string firstCharacterName, string firstMovieName)
        {
            var client = new LocalStaticClient(sampleList);
            var movieListingService = new MovieListingService(client);
            var sortedList          = movieListingService.GetSortedList();
            var firstActor          = sortedList.ToList().FirstOrDefault();

            Assert.IsNotNull(firstActor, "The first actor should not be null");

            var firstCharacter = firstActor.Characters.FirstOrDefault();

            Assert.IsNotNull(firstCharacter, "The first character should not be null");

            Assert.AreEqual(firstCharacterName, firstCharacter.Name, "The first character does not match.");
            Assert.AreEqual(firstActorName, firstActor.ActorName, "The first actor does not match.");
            Assert.AreEqual(firstMovieName, firstCharacter.Movie, "The first movie does not match.");
        }
        public IActionResult Index()
        {
            List <ActorViewModel> movieList;

            try
            {
                var client = new RemoteApiClient(_options.BaseUrl, _options.Resource);
                var movieListingService = new MovieListingService(client);
                movieList = movieListingService.GetSortedList();
            }
            catch (Exception ex)
            {
                movieList             = null;
                ViewData["Exception"] = ex.Message;
            }

            return(View(movieList));
        }