Esempio n. 1
0
        public async Task CanDeleteMovie()
        {
            //Arrange
            var controller = new MoviesController();
            var movie = new Movie()
            {
                Name = "Superman",
                Rating = 11
            };
            movie.Ticket = new Ticket()
            {
                Price = 0.99
            };
            await controller.PostMovie(movie);

            var actionResult = await controller.DeleteMovie(movie.Name);
            
            Assert.IsInstanceOfType(actionResult, typeof(OkNegotiatedContentResult<Movie>));

            await controller.DeleteMovie(movie.Name);
        }
Esempio n. 2
0
        public async Task CanCreateMovie()
        {
            //Arrange
            var controller = new MoviesController();
            var movieName = "Superman";
            var movie = new Movie
            {
                Name = movieName,
                Rating = 11,
                Ticket = new Ticket()
                {
                    Price = 0.99
                }
            };

            var actionResult = await controller.PostMovie(movie)
                               as CreatedAtRouteNegotiatedContentResult<Movie>;

            Assert.AreEqual(movieName, actionResult.Content.Name);

            await controller.DeleteMovie(movieName);
        }
Esempio n. 3
0
        public async Task BuyTicket()
        {
            var shopController = new ShopController();
            var movieController = new MoviesController();
            var ticketQuantity = 23;
            var movie = new Movie()
            {
                Name = "Batman",
                Rating = 6.7,
                Ticket = new Ticket()
                {
                    Price = 2.99,
                    Quantity = ticketQuantity
                }
            };
            await movieController.PostMovie(movie);

            var result = await shopController.BuyTicket(movie.Name) as OkNegotiatedContentResult<Ticket>;

            Assert.IsNotNull(result);
            Assert.AreEqual(ticketQuantity - 1, result.Content.Quantity);

            await movieController.DeleteMovie(movie.Name);
        }