Beispiel #1
0
        public void ProductionController_GetProductionById_Pass()
        {
            // Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

            var theater = new Theater()
            {
                TheaterName   = "Some Theater",
                StreetAddress = "Theater St",
                State         = "CA",
                City          = "LA",
                CompanyName   = "Regal",
                Country       = "US",
                PhoneNumber   = "123456789"
            };

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();

            var productionService = new ProductionService(dbcontext);

            var production = new Production
            {
                ProductionName    = "The Pajama Game",
                DirectorFirstName = "Doris",
                DirectorLastName  = "Day",
                City          = "San Diego",
                StateProvince = "California",
                Country       = "U.S",
                TheaterID     = theater.TheaterID,
                Street        = "123 Sesame St",
                Zipcode       = "91911"
            };

            productionService.CreateProduction(production);
            dbcontext.SaveChanges();

            var productionController = new ProductionController();

            // Act
            var actionResult = productionController.GetProductionById(production.ProductionID);

            var response = actionResult as OkNegotiatedContentResult <Production>;


            productionService.DeleteProduction(response.Content.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();

            // Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.AreEqual(production.ProductionID, response.Content.ProductionID);
        }