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);
        }
Exemplo n.º 2
0
        public void Permission_DeletePermission_Pass()
        {
            //Arrange
            var aString           = "Rate Show";
            var permission        = new Permission(aString);
            var context           = new BroadwayBuilderContext();
            var permissionService = new PermissionService(context);

            var expected = true;
            var actual   = false;

            //Act
            permissionService.CreatePermission(permission);
            context.SaveChanges();
            permissionService.DeletePermission(permission);
            var save = context.SaveChanges();

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

            //Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
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();
        }
        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 GetResumeById_Should_Pass()
        {
            //Arrange
            var context       = new BroadwayBuilderContext();
            var resumeService = new ResumeService(context);
            var userService   = new UserService(context);
            //var expected = true;
            //var actual = false;
            var user = new User("*****@*****.**", "FN", "LN", 19, new DateTime(1994, 1, 7), "LA", "CA", "USA", true);

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

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

            resumeService.CreateResume(resume);
            var results = context.SaveChanges();

            //Act
            var GetResume = resumeService.GetResumeById(resume.ResumeID);

            //Assert
            Assert.AreEqual(resume.ResumeID, GetResume.ResumeID);
            Assert.AreEqual(resume.UserId, GetResume.UserId);
            resumeService.DeleteResume(resume);
            userService.DeleteUser(user);
            context.SaveChanges();
        }
        public void DisableUser_Pass()
        {
            //Arrange
            var context     = new BroadwayBuilderContext();
            var userService = new UserService(context);

            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);

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

            var expected = false;
            var actual   = true;

            //Act
            User DisabledUser = userService.DisableAccount(user);

            context.SaveChanges();
            actual = DisabledUser.isEnabled;

            userService.DeleteUser(user);
            context.SaveChanges();
            //Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 7
0
        public void RoleService_DeleteRole_Pass()
        {
            // Arrange
            var NewRole = new Role("GENERAL", true);

            bool expected = true;
            bool actual   = false;

            var context     = new BroadwayBuilderContext();
            var roleService = new RoleService(context);

            // Act
            roleService.CreateRole(NewRole);
            context.SaveChanges();

            roleService.DeleteRole(NewRole);
            var numOfAffectedRows = context.SaveChanges();

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

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 8
0
        public void RoleService_GetRole_Pass()
        {
            // Arrange

            string role = "ADMIN";

            var NewRole = new Role(role, true);

            var expected = NewRole;

            var context     = new BroadwayBuilderContext();
            var roleService = new RoleService(context);

            // Act
            roleService.CreateRole(NewRole);
            context.SaveChanges();

            var actual = roleService.GetRole(NewRole.RoleID);

            roleService.DeleteRole(NewRole);
            context.SaveChanges();


            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public void DeleteResume_Should_Pass()
        {
            //Arrange
            var context       = new BroadwayBuilderContext();
            var resumeService = new ResumeService(context);
            var userService   = new UserService(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();

            //Act
            resumeService.DeleteResume(resume);
            var results = context.SaveChanges();

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

            //Assert
            Assert.AreEqual(expected, actual);

            userService.DeleteUser(user);
            context.SaveChanges();
        }
        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);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
        }
        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);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
        public IHttpActionResult DeleteUserFromSSO([FromBody] LoginRequestModel request)
        {
            using (var _dbcontext = new BroadwayBuilderContext())
            {
                try
                {
                    ControllerHelper.ValidateLoginRequestModel(ModelState, request);

                    Guid userSsoId = ControllerHelper.ParseAndCheckId(request.SSOUserId);

                    SignatureService signatureService = new SignatureService();
                    if (!signatureService.IsValidClientRequest(request.SSOUserId, request.Email, request.Timestamp, request.Signature))
                    {
                        return(Content(HttpStatusCode.Unauthorized, "Invalid Signature Token"));
                    }

                    UserService userService = new UserService(_dbcontext);
                    var         user        = userService.GetUser(request.Email);
                    userService.DeleteUser(request.Email);

                    _dbcontext.Sessions.RemoveRange(_dbcontext.Sessions.Where(o => o.UserId == user.UserId));
                    _dbcontext.SaveChanges();

                    return(Ok("User deleted"));
                }
                catch (Exception e)
                {
                    return(InternalServerError(e));
                }
            }
        }
        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);
            }
        }
Exemplo n.º 26
0
        public IHttpActionResult LogoutFromSSO([FromBody] LogoutRequestModel request)
        {
            using (var _dbcontext = new BroadwayBuilderContext())
            {
                try
                {
                    ControllerHelper.ValidateLoginRequestModel(ModelState, request);

                    //Guid userSsoId = ControllerHelper.ParseAndCheckId(request.SSOUserId);

                    //SignatureService signatureService = new SignatureService();
                    //if (!signatureService.IsValidClientRequest(request.SSOUserId, request.Email, request.Timestamp, request.Signature))
                    //{
                    //    return Content(HttpStatusCode.Unauthorized, "Invalid Signature Token");
                    //}

                    _dbcontext.Sessions.Remove(_dbcontext.Sessions
                                               .Where(o => o.Signature == request.Signature)
                                               .First());
                    _dbcontext.SaveChanges();

                    return(Ok("User logged out"));
                }
                catch (Exception e)
                {
                    return(InternalServerError(e));
                }
            }
        }
Exemplo n.º 27
0
        public IHttpActionResult CreateUser([FromBody] User user)
        {
            using (var dbcontext = new BroadwayBuilderContext())
            {
                var userService = new UserService(dbcontext);

                try
                {
                    if (user.Username == null)
                    {
                        throw new Exception();
                    }
                    userService.CreateUser(user);
                    dbcontext.SaveChanges();

                    return(Content((HttpStatusCode)201, "User Created"));
                }
                // Todo: add proper error handling
                catch (Exception e)
                {
                    Console.Out.WriteLine(e.StackTrace);
                    return(Content((HttpStatusCode)400, "Must provide a Unique User Name"));
                }
            }
        }
Exemplo n.º 28
0
        public IHttpActionResult UserCompleteRegistration([FromBody] UserCompleteRegistrationRequestModel userData)
        {
            var token = ControllerHelper.GetTokenFromAuthorizationHeader(Request.Headers);

            using (var _db = new BroadwayBuilderContext())
            {
                UserService userService = new UserService(_db);

                var user = userService.GetUserByToken(token);

                if (user.IsComplete)
                {
                    return(BadRequest("User is already registered"));
                }

                user.FirstName     = userData.FirstName;
                user.LastName      = userData.LastName;
                user.City          = userData.City;
                user.StreetAddress = userData.StreetAddress;
                user.StateProvince = userData.StateProvince;
                user.Country       = userData.Country;
                user.IsComplete    = true;
                user.IsEnabled     = true;

                userService.UpdateUser(user);

                _db.SaveChanges();
            }

            return(Ok());
        }
 public IHttpActionResult CreateTheaterJob([FromBody] TheaterJobPosting theaterJob)
 {
     using (var dbContext = new BroadwayBuilderContext())
     {
         TheaterJobPostingService jobService = new TheaterJobPostingService(dbContext);
         try
         {
             if (theaterJob == null)
             {
                 return(Content((HttpStatusCode)400, "That job posting does not exist"));
             }
             jobService.CreateTheaterJob(theaterJob);
             var results = dbContext.SaveChanges();
             if (results <= 0)
             {
                 return(Content((HttpStatusCode)500, "There appears to be no additions made. The Job posting was not created"));
             }
             TheaterJobResponseModel theaterJobResponseModel = new TheaterJobResponseModel(theaterJob);
             return(Content((HttpStatusCode)201, theaterJobResponseModel));
         }
         catch (DbEntityValidationException)
         {
             return(Content((HttpStatusCode)500, "Unable to create the requested job posting"));
         }
         catch (Exception e)//needs to be updated
         {
             return(Content((HttpStatusCode)400, e.Message));
         }
     }
 }
        public IHttpActionResult ApplyToJob([FromUri] int id, [FromUri] int helpwantedid)
        {
            try
            {
                using (var dbContext = new BroadwayBuilderContext())
                {
                    var    resumeService = new ResumeService(dbContext);
                    Resume resume        = resumeService.GetResumeByUserID(id);
                    if (resume == null)//check if user has already submitted a resume; null
                    {
                        return(Content((HttpStatusCode)404, "No resume on file"));
                    }
                    var theaterJobService = new TheaterJobPostingService(dbContext);
                    TheaterJobPosting job = theaterJobService.GetTheaterJob(helpwantedid);
                    if (job == null)//check if job exists
                    {
                        return(Content((HttpStatusCode)404, "No job on file"));
                    }

                    var resumeJobPosting = new ResumeTheaterJob(job.HelpWantedID, resume.ResumeID);
                    var resumeJobService = new ResumeTheaterJobService(dbContext);
                    resumeJobService.CreateResumeTheaterJob(resumeJobPosting);
                    var result = dbContext.SaveChanges();
                    if (result > 0)//check if any rows were affected in the database
                    {
                        return(Content((HttpStatusCode)200, "Successfully Applied!"));
                    }
                    return(Content((HttpStatusCode)500, "Wasn't able to successfully apply"));
                }
            }
            catch (Exception e)
            {
                return(Content((HttpStatusCode)400, e.Message));
            }
        }