public void TheaterJobService_ReadTheaterJobPosting_Pass() { //Arrange 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"); var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType"); //Act theaterService.CreateTheater(theater); theaterJobService.CreateTheaterJob(jobPosting); dbcontext.SaveChanges(); TheaterJobPosting getTheaterJob = theaterJobService.GetTheaterJob(jobPosting); if (getTheaterJob != null) { actual = true; } theaterJobService.DeleteTheaterJob(jobPosting); dbcontext.SaveChanges(); theaterService.DeleteTheater(theater); dbcontext.SaveChanges(); //Assert Assert.AreEqual(expected, actual); }
public void PostShouldAddTheaterJob()//need to update { var dbcontext = new BroadwayBuilderContext(); var theaterService = new TheaterService(dbcontext); var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323"); theaterService.CreateTheater(theater); dbcontext.SaveChanges(); //Arrange 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 <TheaterJobPosting>; var content = response.Content; var jobservice = new TheaterJobService(dbcontext); jobservice.DeleteTheaterJob(content); theaterService.DeleteTheater(theater); dbcontext.SaveChanges(); ////Assert Assert.IsNotNull(response); Assert.IsNotNull(response.Content); //Assert.AreEqual("Theater Job Posting Created",content); Assert.AreEqual((HttpStatusCode)201, response.StatusCode); }
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 IHttpActionResult DeleteTheaterJob(int helpWantedId) { using (var dbcontext = new BroadwayBuilderContext()) { TheaterJobService service = new TheaterJobService(dbcontext); TheaterJobPosting job = service.GetTheaterJob(helpWantedId); try { service.DeleteTheaterJob(job); if (job == null) { return(Content((HttpStatusCode)404, "That Job Listing does not exist")); } var results = dbcontext.SaveChanges(); if (results > 0) { return(Content((HttpStatusCode)202, "Successfully Deleted Job Posting")); } else { throw new ZeroAffectedRowsException(); } } catch (ZeroAffectedRowsException) { return(Content((HttpStatusCode)500, "There appears to be no changes made in the database. The job posting wasn't deleted")); } catch (DbEntityValidationException) { return(Content((HttpStatusCode)500, "Unable to delete the job posting")); } catch (Exception e) { return(Content((HttpStatusCode)400, e.Message)); } } }