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

            var theater = new Theater()
            {
                TheaterName   = "The Magicians",
                StreetAddress = "Pantene",
                State         = "CA",
                City          = "LA",
                CompanyName   = "123 Sesame St",
                Country       = "US",
                PhoneNumber   = "123456789"
            };

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

            var productionService = new ProductionService(dbcontext);

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

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

            var date = DateTime.Parse("3/28/2019 3:22:29 PM");
            var time = TimeSpan.Parse("11:30:00");

            var productionDateTime = new ProductionDateTime(production.ProductionID, date, time);

            productionService.CreateProductionDateTime(production.ProductionID, productionDateTime);
            dbcontext.SaveChanges();

            var productionController = new ProductionController();

            // Act
            var actionResult = productionController.deleteProductiondateTime(productionDateTime.ProductionDateTimeId, productionDateTime);
            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 date time deleted succesfully!", response.Content);
        }