Esempio n. 1
0
        public void ProductionService_DeleteProductionThatDoesNotExist_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();

            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();

            var expected = true;
            var actual   = false;

            // Act
            try
            {
                productionService.DeleteProduction(production.ProductionID);
            }
            catch (ProductionNotFoundException ex)
            {
                actual = true;
            }

            // Assert
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void DeleteShouldDeleteTheaterJob()
        {
            var dbcontext         = new BroadwayBuilderContext();
            var theaterService    = new TheaterService(dbcontext);
            var theaterJobService = new TheaterJobPostingService(dbcontext);

            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();
            var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType");

            theaterJobService.CreateTheaterJob(jobPosting);
            dbcontext.SaveChanges();
            var controller = new HelpWantedController();

            //Act
            var actionResult = controller.DeleteTheaterJob(jobPosting.HelpWantedID);
            var response     = actionResult as NegotiatedContentResult <string>;
            var content      = response.Content;

            var dbcontext2      = new BroadwayBuilderContext();
            var theaterService2 = new TheaterService(dbcontext2);

            theaterService2.DeleteTheater(theater);
            dbcontext2.SaveChanges();
            //Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.AreEqual((HttpStatusCode)200, response.StatusCode);
        }
        public void TheaterService_DeleteNonExistantTheater_Pass()
        {
            // Arrange
            var context        = new BroadwayBuilderContext();
            var theater        = new Theater("Performing Arts", "Long Beach Shakespeare Company", "40855 Theater Lane", "Long Beach", "CA", "USA", "555-955-8955");
            var theaterService = new TheaterService(context);
            var expected       = true;
            var actual         = false;

            // Act
            try
            {
                theaterService.DeleteTheater(theater);
                var changesMade = context.SaveChanges();
                if (changesMade > 0)
                {
                    actual = true;
                }
            }
            catch (Exception)
            {
                actual = false;
            }

            // Assert
            finally
            {
                Assert.AreNotEqual(expected, actual);
            }
        }
Esempio n. 4
0
        public void GetShouldGetAllTheaterJobs()
        {
            var dbcontext         = new BroadwayBuilderContext();
            var theaterService    = new TheaterService(dbcontext);
            var theaterJobService = new TheaterJobPostingService(dbcontext);

            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();
            var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType");

            theaterJobService.CreateTheaterJob(jobPosting);
            dbcontext.SaveChanges();
            //Arrange
            var controller    = new HelpWantedController();
            var currentPage   = 1;
            var numberOfItems = 100;
            //Act
            var actionResult = controller.GetTheaterJobs(theater.TheaterID, currentPage, numberOfItems);
            var response     = actionResult as NegotiatedContentResult <TheaterJobResponseList>;

            //var content = response.Content;

            //Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.AreEqual((HttpStatusCode)200, response.StatusCode);

            theaterJobService.DeleteTheaterJob(jobPosting.HelpWantedID);
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
        }
Esempio n. 5
0
        public void PostShouldAddTheaterJob()//need to update
        {
            //Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);
            var theater        = new Theater("someTheater2", "Regal", "theater st", "LA", "CA", "US", "323323");

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();
            var controller        = new HelpWantedController();
            TheaterJobPosting job = new TheaterJobPosting(theater.TheaterID, "test", "test", "test", "test", "test", "testType");

            //Act
            var actionResult = controller.CreateTheaterJob(job);
            var response     = actionResult as NegotiatedContentResult <TheaterJobResponseModel>;
            var content      = response.Content;

            //Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.AreEqual((HttpStatusCode)201, response.StatusCode);

            var jobservice = new TheaterJobPostingService(dbcontext);

            jobservice.DeleteTheaterJob(content.HelpWantedID);
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
        }
        public void TheaterService_UpdateTheater_Pass()
        {
            // Arrange
            var context        = new BroadwayBuilderContext();
            var theater        = new Theater("Performing Arts", "Long Beach Shakespeare Company", "40855 Theater Lane", "Long Beach", "CA", "USA", "555-955-8955");
            var theaterService = new TheaterService(context);

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

            // Act
            theater.TheaterName = "Natural History";
            theater.CompanyName = "Different Company";
            var expected = theater;
            //var actual = theater;
            var actual = theaterService.UpdateTheater(theater);

            //theater.StreetAddress = "125 Bogus Lane";
            context.SaveChanges();

            theaterService.DeleteTheater(theater);
            context.SaveChanges();

            // Assert
            Assert.AreEqual(expected.TheaterName, actual.TheaterName);
            Assert.AreEqual(expected.CompanyName, actual.CompanyName);
            Assert.AreEqual(expected.StreetAddress, actual.StreetAddress);
            Assert.AreEqual(expected.City, actual.City);
            Assert.AreEqual(expected.State, actual.State);
            Assert.AreEqual(expected.Country, actual.Country);
            Assert.AreEqual(expected.PhoneNumber, actual.PhoneNumber);
        }
        public void PutShouldUpdateTheaterJob()
        {
            var dbcontext         = new BroadwayBuilderContext();
            var theaterService    = new TheaterService(dbcontext);
            var theaterJobService = new TheaterJobService(dbcontext);
            //var expected = true;
            //var actual = false;

            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();
            var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType");

            theaterJobService.CreateTheaterJob(jobPosting);
            dbcontext.SaveChanges();
            var controller = new HelpWantedController();

            //Act
            jobPosting.Description = "testing";
            var actionResult = controller.EditTheaterJob(jobPosting);
            var response     = actionResult as NegotiatedContentResult <string>;
            var content      = response.Content;

            theaterJobService.DeleteTheaterJob(jobPosting);
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            ////Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.AreEqual("Updated Job Posting", content);
            Assert.AreEqual((HttpStatusCode)202, response.StatusCode);
        }
        public void TheaterJobService_DeleteTheaterJobPosting_Pass()
        {
            //Arrange
            var dbcontext         = new BroadwayBuilderContext();
            var theaterService    = new TheaterService(dbcontext);
            var theaterJobService = new TheaterJobPostingService(dbcontext);
            var expected          = true;
            var actual            = false;

            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

            var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType");

            //Act
            theaterService.CreateTheater(theater);
            //dbcontext.SaveChanges();
            theaterJobService.CreateTheaterJob(jobPosting);
            dbcontext.SaveChanges();
            theaterJobService.DeleteTheaterJob(jobPosting.HelpWantedID);
            var results = dbcontext.SaveChanges();

            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            if (results > 0)
            {
                actual = true;
            }
            //Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 9
0
        public void PutShouldUpdateTheater_Pass()
        {
            // Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);
            var theater        = new Theater("TEST", "Theater controller", "PUT", "UpdateTheater", "CA", "US", "1355");

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();
            var theaterController = new TheaterController();

            // Act
            theater.State       = "CHANGED DATA";
            theater.City        = "CHANGED DATA";
            theater.PhoneNumber = "CHanged DATA";
            var actionResult = theaterController.UpdateTheater(theater);
            var response     = actionResult as NegotiatedContentResult <Theater>;
            var content      = response.Content;

            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            // Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(content);
            Assert.AreEqual((HttpStatusCode)200, response.StatusCode);
        }
Esempio n. 10
0
        public void GetShouldGetTheaterByName()
        {
            //Arrange
            var dbcontext = new BroadwayBuilderContext();
            var theater   = new Theater("createTheater", "Regal", "theater st", "LA", "CA", "US", "323323");
            var service   = new TheaterService(dbcontext);

            service.CreateTheater(theater);
            dbcontext.SaveChanges();
            var controller = new TheaterController();

            //Act
            var actionResult = controller.GetTheaterByName(theater.TheaterName);
            var response     = actionResult as NegotiatedContentResult <Theater>;
            var content      = response.Content;

            //Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.AreEqual(theater.TheaterName, content.TheaterName);
            Assert.AreEqual((HttpStatusCode)200, response.StatusCode);

            service.DeleteTheater(theater);
            dbcontext.SaveChanges();
        }
Esempio n. 11
0
        public void ProductionController_CreateProductionDateTime_Pass()
        {
            // Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

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

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

            var production = new Production()
            {
                ProductionName    = "The Lion King 2",
                DirectorFirstName = "Jane",
                DirectorLastName  = "Doe",
                Street            = "Anahiem",
                City          = "Long Beach",
                StateProvince = "California",
                Country       = "United States",
                Zipcode       = "919293",
                TheaterID     = theater.TheaterID
            };

            var productionService = new ProductionService(dbcontext);

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

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

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

            var productionController = new ProductionController();

            // Act
            var actionResult = productionController.CreateProductionDateTime(production.ProductionID, productionDateTime);
            var response     = actionResult as OkNegotiatedContentResult <string>;

            productionService.DeleteProductionDateTime(productionDateTime);
            dbcontext.SaveChanges();
            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            // Assert
            Assert.IsNotNull(response);
            Assert.AreEqual("Production Date and time have been added!", response.Content);
        }
Esempio n. 12
0
        public void ProductionService_CreateProduction_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 production = new Production()
            {
                ProductionName    = "The Lion King",
                DirectorFirstName = "Jane",
                DirectorLastName  = "Doe",
                Street            = "Anahiem",
                City          = "Long Beach",
                StateProvince = "California",
                Country       = "United States",
                Zipcode       = "919293",
                TheaterID     = theater.TheaterID
            };

            var expected = true;
            var actual   = false;

            var productionService = new ProductionService(dbcontext);


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

            if (production.ProductionID > 0)
            {
                actual = true;
            }

            // Assert
            var dbcontext_         = new BroadwayBuilderContext();
            var productionService_ = new ProductionService(dbcontext_);

            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected, actual);
        }
        public void CreateResumeTheaterJob_Should_NotCreateSameResumeTheaterJob()
        {
            //Arrange
            var context                 = new BroadwayBuilderContext();
            var resumeService           = new ResumeService(context);
            var userService             = new UserService(context);
            var theaterService          = new TheaterService(context);
            var theaterJobService       = new TheaterJobPostingService(context);
            var resumeTheaterJobService = new ResumeTheaterJobService(context);

            var expected = true;
            var actual   = false;

            var user = new User("*****@*****.**", "FN", "LN", 19, new DateTime(1994, 1, 7), "address", "LA", "CA", "USA", true, Guid.NewGuid());

            userService.CreateUser(user);
            context.SaveChanges();

            var resume = new Resume(user.UserId, Guid.NewGuid());

            resumeService.CreateResume(resume);
            context.SaveChanges();

            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

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

            var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType");

            theaterJobService.CreateTheaterJob(jobPosting);
            context.SaveChanges();

            //Act
            var resumeTheaterJob = new ResumeTheaterJob(jobPosting.HelpWantedID, resume.ResumeID);

            resumeTheaterJobService.CreateResumeTheaterJob(resumeTheaterJob);
            context.SaveChanges();

            try
            {
                resumeTheaterJobService.CreateResumeTheaterJob(resumeTheaterJob);
            }
            catch
            {
                actual = true;
            }
            resumeTheaterJobService.DeleteResumeTheaterJob(resumeTheaterJob);
            resumeService.DeleteResume(resume);
            theaterJobService.DeleteTheaterJob(jobPosting.HelpWantedID);
            userService.DeleteUser(user);
            theaterService.DeleteTheater(theater);
            context.SaveChanges();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 14
0
        public void GetFromAPI_AddOrUpdate_Delete_Theater_Test()
        {
            var theater = theaterService.GetFromAPI(8);

            theater.PosterBig = "https://relax.com.ua/wp-content/media/kiew/2013/02/floren.jpg";
            this.TraceTheater(theater);
            //theaterService.AddOrUpdateTheater(theater);
            theaterService.DeleteTheater(theater.Id);
        }
Esempio n. 15
0
        public void ProductionService_GetProductionById_Pass()
        {
            // Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

            var theater = new Theater()
            {
                TheaterName   = "The Language",
                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",
                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 expected = true;
            var actual   = false;

            // Act
            var readProduction = productionService.GetProduction(production.ProductionID);

            if (readProduction != null)
            {
                actual = true;
            }

            // Assert
            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected, actual);
        }
Esempio n. 16
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);
        }
        public void ProductionService_CreateProductionDateTime_Pass()
        {
            //Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

            var theater = new Theater("The Magicians", "Regal", "theater st", "LA", "CA", "US", "323323");

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

            var productionService = new ProductionService(dbcontext);

            var productionName    = "The Lion King";
            var directorFirstName = "Joan";
            var directorLastName  = "Doe";
            var street            = "123 Anahiem St";
            var city          = "Long Beach";
            var stateProvince = "California";
            var country       = "United States";
            var zipcode       = "919293";

            var production = new Production(theater.TheaterID, productionName, directorFirstName, directorLastName, street, city, stateProvince, country, zipcode);

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

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

            /* Info: Had to cast to int because in production entity model int was made into a Nullable<int> or int? for data validation purposes
             * If we make model in frontend then we can remove this cast to int and it will make things cleaner
             */
            var productionDateTime = new ProductionDateTime((int)production.ProductionID, date, time);

            var expected = true;
            var actual   = false;


            // Act
            productionService.CreateProductionDateTime(productionDateTime);
            dbcontext.SaveChanges();

            if (productionDateTime.ProductionDateTimeId > 0)
            {
                actual = true;
            }

            // Assert
            productionService.DeleteProduction(production);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected, actual);
        }
Esempio n. 18
0
        public void AuthorizationService_UserHasPermission_Pass()
        {
            // Arrange
            BroadwayBuilderContext broadwayBuilderContext = new BroadwayBuilderContext();

            var username      = "******";
            var firstName     = "Abi";
            var lastName      = "Castro";
            int age           = 24;
            var dob           = new DateTime(1994, 1, 7);
            var city          = "San Diego";
            var stateProvince = "California";
            var country       = "United States";
            var enable        = true;

            var user       = new User(username, firstName, lastName, age, dob, city, stateProvince, country, enable);
            var permission = new Permission("RateShow", true);
            var theater    = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");


            var expected = true;
            var actual   = false;


            var service           = new AuthorizationService(broadwayBuilderContext);
            var userService       = new UserService(broadwayBuilderContext);
            var theaterService    = new TheaterService(broadwayBuilderContext);
            var permissionService = new PermissionService(broadwayBuilderContext);

            //Adding data into tables
            permissionService.CreatePermission(permission);
            broadwayBuilderContext.SaveChanges();
            userService.CreateUser(user);
            broadwayBuilderContext.SaveChanges();
            theaterService.CreateTheater(theater);
            broadwayBuilderContext.SaveChanges();
            userService.AddUserPermission(user, permission, theater);
            broadwayBuilderContext.SaveChanges();


            // Act
            actual = service.HasPermission(user, permission, theater);

            UserPermission userPermission = userService.GetUserPermission(user, permission, theater);

            userService.DeleteUserPermission(userPermission);
            broadwayBuilderContext.SaveChanges();
            userService.DeleteUser(user);
            permissionService.DeletePermission(permission);
            theaterService.DeleteTheater(theater);
            broadwayBuilderContext.SaveChanges();

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void ProductionService_UpdateProduction_Pass()
        {
            // Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

            var theater = new Theater("The Magicians", "Regal", "theater st", "LA", "CA", "US", "323323");

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

            var productionService = new ProductionService(dbcontext);

            var productionName    = "The Lion King";
            var directorFirstName = "Joan";
            var directorLastName  = "Doe";
            var street            = "123 Anahiem St";
            var city          = "Long Beach";
            var stateProvince = "California";
            var country       = "United States";
            var zipcode       = "919293";

            var production = new Production(theater.TheaterID, productionName, directorFirstName, directorLastName, street, city, stateProvince, country, zipcode);

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


            production.ProductionName   = "The Lion King 2";
            production.StateProvince    = "Utah";
            production.DirectorLastName = "Mangos";

            var expected = new List <string>()
            {
                "The Lion King 2",
                "Utah",
                "Mangos"
            };


            // Act
            var actual = productionService.UpdateProduction(production);

            dbcontext.SaveChanges();

            // Assert
            productionService.DeleteProduction(production);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected[0], actual.ProductionName);
            Assert.AreEqual(expected[1], actual.StateProvince);
            Assert.AreEqual(expected[2], actual.DirectorLastName);
        }
        public void ProductionService_CreateProduction_Pass()
        {
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

            // Arrange
            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

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

            var productionName    = "The Lion King";
            var directorFirstName = "Jane";
            var directorLastName  = "Doe";
            var street            = "Anahiem";
            var city          = "Long Beach";
            var stateProvince = "California";
            var country       = "United States";
            var zipcode       = "919293";


            var production = new Production(theater.TheaterID, productionName, directorFirstName, directorLastName, street, city, stateProvince, country, zipcode);

            var expected = true;
            var actual   = false;

            var productionService = new ProductionService(dbcontext);


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

            if (production.ProductionID > 0)
            {
                actual = true;
            }

            // Assert

            var dbcontext_         = new BroadwayBuilderContext();
            var productionService_ = new ProductionService(dbcontext_);

            productionService.DeleteProduction(production);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected, actual);
        }
Esempio n. 21
0
        public void AuthorizationService_UserHasPermission_Pass()
        {
            // Arrange
            BroadwayBuilderContext broadwayBuilderContext = new BroadwayBuilderContext();

            var username      = "******";
            var firstName     = "Abi";
            var lastName      = "Castro";
            int age           = 24;
            var dob           = new DateTime(1994, 1, 7);
            var streetAddress = "address1";
            var city          = "San Diego";
            var stateProvince = "California";
            var country       = "United States";
            var enable        = true;

            var user       = new User(username, firstName, lastName, age, dob, streetAddress, city, stateProvince, country, enable, Guid.NewGuid());
            var permission = new Permission("RateShow", true);
            var theater    = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");


            var expected = true;
            var actual   = false;


            var service           = new AuthorizationService(broadwayBuilderContext);
            var userService       = new UserService(broadwayBuilderContext);
            var theaterService    = new TheaterService(broadwayBuilderContext);
            var permissionService = new PermissionService(broadwayBuilderContext);

            //Adding data into tables
            userService.CreateUser(user);
            theaterService.CreateTheater(theater);
            broadwayBuilderContext.SaveChanges();
            userService.AddUserRole(user.UserId, DataAccessLayer.Enums.RoleEnum.SysAdmin);
            broadwayBuilderContext.SaveChanges();


            // Act
            actual = service.HasPermission(user, DataAccessLayer.Enums.PermissionsEnum.ActivateAbusiveAccount);

            userService.DeleteUser(user);
            theaterService.DeleteTheater(theater);
            broadwayBuilderContext.SaveChanges();

            // Assert
            Assert.AreEqual(expected, actual);
        }
 public IHttpActionResult DeleteTheater([FromBody] Theater theater)
 {
     using (var dbcontext = new BroadwayBuilderContext())
     {
         try
         {
             var theaterService = new TheaterService(dbcontext);
             theaterService.DeleteTheater(theater);
             dbcontext.SaveChanges();
             return(Content((HttpStatusCode)200, "Theater Successfully Deleted"));
         }
         catch
         {
             return(Content((HttpStatusCode)404, "The theater could not be found"));
         }
     }
 }
Esempio n. 23
0
        public void ProductionJobService_ReadProductionJobPosting_Pass()
        {
            //Arrange
            var dbcontext            = new BroadwayBuilderContext();
            var theaterService       = new TheaterService(dbcontext);
            var productionService    = new ProductionService(dbcontext);
            var productionJobService = new ProductionJobService(dbcontext);
            var expected             = true;
            var actual = false;

            var theater    = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");
            var production = new Production(theater.TheaterID, "someName", "directorln", "directorfn", "street", "city", "state", "country", "zip");

            theaterService.CreateTheater(theater);
            productionService.CreateProduction(production);
            dbcontext.SaveChanges();

            /* Info: Had to cast to int because in production entity model int was made into a Nullable<int> or int? for data validation purposes
             *  If we make model in frontend then we can remove this cast to int and it will make things cleaner
             */
            var jobPosting = new ProductionJobPosting((int)production.ProductionID, "intern", "some decription", "title", "hours", "some requirements");

            //Act
            productionJobService.CreateProductionJob(jobPosting);
            dbcontext.SaveChanges();
            ProductionJobPosting productionJobPost = productionJobService.GetProductionJob(jobPosting);

            if (productionJobPost != null)
            {
                actual = true;
            }

            productionJobService.DeleteProductionJob(jobPosting);
            productionService.DeleteProduction(production);
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void TheaterService_DeleteTheater_Pass()
        {
            // Arrange
            var context        = new BroadwayBuilderContext();
            var theater        = new Theater("Performing Arts", "Long Beach Shakespeare Company", "40855 Theater Lane", "Long Beach", "CA", "USA", "555-955-8955");
            var theaterService = new TheaterService(context);
            var expected       = true;
            var actual         = false;

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

            // Act
            theaterService.DeleteTheater(theater);
            if (context.SaveChanges() > 0)
            {
                actual = true;
            }

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 25
0
        public void ProductionController_UpdateProductionDateTime_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();

            productionDateTime.Date = DateTime.Parse("3/27/2019 3:22:29 PM");
            productionDateTime.Time = TimeSpan.Parse("9:30:00");

            var productionController = new ProductionController();

            // Act
            var actionResult = productionController.updateProductionDateTime(productionDateTime.ProductionDateTimeId, productionDateTime);

            var response = actionResult as OkNegotiatedContentResult <ProductionDateTime>;
            var updatedProductionDateTime = response.Content;

            var expected = new
            {
                DateTime = DateTime.Parse("3/27/2019 3:22:29 PM"),
                TimeSpan = TimeSpan.Parse("9:30:00")
            };

            var actual = updatedProductionDateTime;

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

            // Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(productionDateTime.ProductionDateTimeId, updatedProductionDateTime.ProductionDateTimeId);
            Assert.AreEqual(expected.DateTime, actual.Date);
            Assert.AreEqual(expected.TimeSpan, actual.Time);
        }
Esempio n. 26
0
        public void ProductionService_SavePhotos_Pass()
        {
            // Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

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

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

            var production = new Production()
            {
                ProductionName    = "The Lion King 2",
                DirectorFirstName = "Jane",
                DirectorLastName  = "Doe",
                Street            = "Anahiem",
                City          = "Long Beach",
                StateProvince = "California",
                Country       = "United States",
                Zipcode       = "919293",
                TheaterID     = theater.TheaterID
            };

            var productionService = new ProductionService(dbcontext);

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

            var mockedPostedPdfFile = new MockPostedFile("jpg", 5000000, "productionPhotoTestFile.jpg");

            var extension = Path.GetExtension(mockedPostedPdfFile.FileName);

            var currentDirectory = ConfigurationManager.AppSettings["FileDir"];

            var dir      = Path.Combine(currentDirectory, "Photos/");
            var subdir   = Path.Combine(dir, $"Production{production.ProductionID}/");
            var filePath = Path.Combine(subdir, $"{production.ProductionID}-0{extension}");


            var expected = true;
            var actual   = false;

            // Act
            productionService.SavePhoto(production.ProductionID, mockedPostedPdfFile);

            if (File.Exists(filePath))
            {
                actual = true;
            }
            // Assert
            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            File.Delete(filePath);
            Directory.Delete(subdir);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 27
0
        public void ProductionController_GetPhotos_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();

            var mockPostedPdfFile1 = new MockPostedFile("jpg", 5000000, "1.jpg");
            var mockPostedPdfFile2 = new MockPostedFile("jpg", 5000000, "2.jpg");

            productionService.SavePhoto(production.ProductionID, mockPostedPdfFile1);
            productionService.SavePhoto(production.ProductionID, mockPostedPdfFile2);

            var currentDirectory = ConfigurationManager.AppSettings["FileDir"];

            var dir    = Path.Combine(currentDirectory, "Photos/");
            var subdir = Path.Combine(dir, $"Production{production.ProductionID}/");

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

            // Need access to contet of the response
            var response = actionResult as OkNegotiatedContentResult <List <string> >;

            var photoUrls = response.Content;

            var expected = true;
            var actual   = false;

            if (photoUrls.Count == 2)
            {
                actual = true;
            }

            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Directory.Delete(subdir, true);

            // Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 28
0
        public void ProductionService_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 expected = true;
            var actual   = false;

            // Act
            productionService.DeleteProductionDateTime(productionDateTime);
            var affectedRows = dbcontext.SaveChanges();

            if (affectedRows > 0)
            {
                actual = true;
            }

            // Assert
            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected, actual);
        }
Esempio n. 29
0
        public void ProductionService_GetProductionsByCurrentDate_Pass()
        {
            // Arrange
            // Arrange
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);

            var theater = new Theater()
            {
                TheaterName   = "The Language",
                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 production1 = new Production()
            {
                ProductionName    = "The Lion King 14",
                DirectorFirstName = "Joan",
                DirectorLastName  = "Doe",
                Street            = "123 Anahiem St",
                City          = "Long Beach",
                StateProvince = "California",
                Country       = "United States",
                Zipcode       = "919293",
                TheaterID     = theater.TheaterID
            };


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

            var production2 = new Production()
            {
                ProductionName    = "The Lion King 15",
                DirectorFirstName = "Joan",
                DirectorLastName  = "Doe",
                Street            = "123 Anahiem St",
                City          = "Long Beach",
                StateProvince = "California",
                Country       = "United States",
                Zipcode       = "919293",
                TheaterID     = theater.TheaterID
            };

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

            var productionDateTime1 = new ProductionDateTime()
            {
                Date         = DateTime.Parse("3/23/2019 3:22:29 PM"),
                Time         = TimeSpan.Parse("10:30:00"),
                ProductionID = production1.ProductionID
            };

            productionService.CreateProductionDateTime(production1.ProductionID, productionDateTime1);
            dbcontext.SaveChanges();

            var productionDateTime2 = new ProductionDateTime()
            {
                Date         = DateTime.Parse("3/29/2019 3:22:29 PM"),
                Time         = TimeSpan.Parse("5:30:00"),
                ProductionID = production2.ProductionID
            };

            productionService.CreateProductionDateTime(production2.ProductionID, productionDateTime2);
            dbcontext.SaveChanges();

            var expected = true;
            var actual   = false;
            // Act
            var readProductionsList = productionService.GetProductionsByCurrentAndFutureDate(new DateTime(2019, 3, 1), null, 1, 10); // Theater id is meant to be null

            if (readProductionsList != null)
            {
                actual = true;
            }

            // Assert
            productionService.DeleteProductionDateTime(productionDateTime2);
            dbcontext.SaveChanges();
            productionService.DeleteProductionDateTime(productionDateTime1);
            dbcontext.SaveChanges();
            productionService.DeleteProduction(production1.ProductionID);
            dbcontext.SaveChanges();
            productionService.DeleteProduction(production2.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected, actual);
        }
Esempio n. 30
0
        public void ProductionService_UpdateProduction_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 Lion King",
                DirectorFirstName = "Jane",
                DirectorLastName  = "Doe",
                Street            = "Anahiem",
                City          = "Long Beach",
                StateProvince = "California",
                Country       = "United States",
                Zipcode       = "919293",
                TheaterID     = theater.TheaterID
            };


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


            production.ProductionName   = "The Lion King 2";
            production.StateProvince    = "Utah";
            production.DirectorLastName = "Mangos";

            var expected = new List <string>()
            {
                "The Lion King 2",
                "Utah",
                "Mangos"
            };


            // Act
            var actual = productionService.UpdateProduction(production);

            dbcontext.SaveChanges();

            // Assert
            productionService.DeleteProduction(production.ProductionID);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            Assert.AreEqual(expected[0], actual.ProductionName);
            Assert.AreEqual(expected[1], actual.StateProvince);
            Assert.AreEqual(expected[2], actual.DirectorLastName);
        }