Пример #1
0
        public void ProductionController_DeleteProduction_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.deleteProduction(production.ProductionID);

            var response = actionResult as OkNegotiatedContentResult <string>;

            var dbcontext_      = new BroadwayBuilderContext();
            var theaterService_ = new TheaterService(dbcontext_);
            var theater_        = theaterService.GetTheaterByID(theater.TheaterID);

            theaterService_.DeleteTheater(theater_);
            dbcontext_.SaveChanges();

            // Assert
            Assert.IsNotNull(response);
            Assert.AreEqual("Production deleted succesfully", response.Content);
        }