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); } }
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 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(); }
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); }
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 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); }
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 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 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 BookController(SeanceService seanceService, MovieService movieService, TheaterService theaterService, BookService bookService) { this.seanceService = seanceService; this.movieService = movieService; this.theaterService = theaterService; this.bookService = bookService; mapperMovieModel = new Mapper(new MapperConfiguration(c => c.CreateMap <Movie, MovieBookModel>())); mapperTheaterModel = new Mapper(new MapperConfiguration(c => c.CreateMap <Theater, TheaterBookModel>())); mapperSeanceModel = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap <Seance, SeanceModel>() .ForMember(d => d.Times, opt => opt.MapFrom(s => s.Times)) )); mapperSeanceDataModel = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap <SeanceData, SeancesModelForTheater>() .ForMember(d => d.MovieModel, opt => opt.MapFrom(src => src.Movies.FirstOrDefault())) .ForMember(d => d.HallModels, opt => opt.MapFrom(src => src.Halls)) .ForMember(d => d.Seances, opt => opt.MapFrom(s => mapperSeanceModel.Map <List <Seance>, List <SeanceModel> >(s.Seances))) .ForMember(d => d.TheaterModel, otp => otp.MapFrom(src => src.Theaters.FirstOrDefault())) )); mapperTimeSeanceModel = new Mapper(new MapperConfiguration(c => c.CreateMap <TimeSeance, TimeSeanceModel>())); mapperPriceModel = new Mapper(new MapperConfiguration(c => c.CreateMap <Price, PriceModel>() .ForMember(d => d.Tariff, o => o.MapFrom(s => SetTariff(s.Type))) )); mapperPurcahse = new Mapper(new MapperConfiguration(c => c.CreateMap <PurchaseModel, Purchase>())); mapperPurchaseModel = new Mapper(new MapperConfiguration(c => c.CreateMap <Purchase, PurchaseModel>())); }
private TheaterService CreateTheaterService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new TheaterService(userId); return(service); }
public IHttpActionResult GetTheaterJobs(int theaterId, int currentPage, int numberOfItems) { using (var dbcontext = new BroadwayBuilderContext()) { try { TheaterService theaterService = new TheaterService(dbcontext); Theater theater = theaterService.GetTheaterByID(theaterId); if (theater == null)//check if theater exists; null if there is no record in the DB { //throw new DbEntityNotFoundException("There is no record of that Theater in our database"); //use Stacktrace class then log? return(Content((HttpStatusCode)404, "There is no record of that Theater in our database")); } TheaterJobPostingService service = new TheaterJobPostingService(dbcontext); int count = 0; //variable to be used for GetAllJobsFromTheater to get the count of Theater job postings found from query var list = service.GetAllJobsFromTheater(theaterId, currentPage, numberOfItems, out count); TheaterJobResponseList theaterJobResponseList = new TheaterJobResponseList(count, list); //create a response model containing the count and List of theater jobs to reduce JSON Hijacking return(Content((HttpStatusCode)200, theaterJobResponseList)); } catch (DbEntityNotFoundException e) { return(Content((HttpStatusCode)404, e.Message)); } catch (Exception e) { return(Content((HttpStatusCode)400, e.Message)); } } }
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); }
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); }
// GET: Theater public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new TheaterService(userId); var model = service.GetTheater(); return(View(model)); }
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); }
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); }
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 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); }
// GET: Theater public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new TheaterService(userId); var model = service.GetTheater(); //return View(model); if (User.IsInRole("Admin")) { return(View("Index", model)); } return(View("ReadOnlyViewIndex", model)); }
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 GetAllTheaters() { using (var dbcontext = new BroadwayBuilderContext()) { TheaterService service = new TheaterService(dbcontext); try { IEnumerable list = service.GetAllTheaters(); return(Content((HttpStatusCode)200, list)); } catch (Exception e) { return(Content((HttpStatusCode)500, "Oops! Something went wrong on our end")); } } }
public IHttpActionResult GetTheaterCount() { using (var dbcontext = new BroadwayBuilderContext()) { try { var theaterService = new TheaterService(dbcontext); int count = theaterService.GetTheaterCount(); return(Content((HttpStatusCode)200, count)); } catch (Exception e) { return(Content((HttpStatusCode)500, "Unable to get count of job postings for theater " + e.Message)); } } }
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")); } } }
public void TheaterService_UpdateNonExistantTheater_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); // Act theater.TheaterName = "Natural History"; theater.CompanyName = "Different Company"; var expected = theater; var actual = theaterService.UpdateTheater(theater); context.SaveChanges(); // Assert Assert.AreNotEqual(expected, actual); }
public IHttpActionResult GetTheaterById(int theaterid) { using (var dbcontext = new BroadwayBuilderContext()) { TheaterService service = new TheaterService(dbcontext); try { Theater theater = service.GetTheaterByID(theaterid); if (theater == null) { throw new Exception(); } return(Content((HttpStatusCode)200, theater)); } catch (Exception) { return(Content((HttpStatusCode)404, "The Theater could not be found")); } } }