public void Find_OneBandId_ReturnBandFromDatabase() { //Arrange Band testBand = new Band("Green Day"); testBand.Save(); //Act Band foundBand = Band.Find(testBand.GetId()); //Assert Assert.Equal(testBand, foundBand); }
public void Save_OneBand_BandSavedToDatabase() { //Arrange Band testBand = new Band("Green Day"); //Act testBand.Save(); List <Band> output = Band.GetAll(); List <Band> verify = new List <Band> { testBand }; //Assert Assert.Equal(verify, output); }
public void Save_OneBand_BandSavedWithCorrectID() { //Arrange Band testBand = new Band("Green Day"); testBand.Save(); Band savedBand = Band.GetAll()[0]; //Act int output = savedBand.GetId(); int verify = testBand.GetId(); //Assert Assert.Equal(verify, output); }
public void SearchName_Name_ReturnBandFromDatabase() { //Arrange Band testBand = new Band("Green Day"); testBand.Save(); //Act List <Band> output = Band.SearchName("Green Day"); List <Band> verify = new List <Band> { testBand }; //Assert Assert.Equal(verify, output); }
public void AddBand_AlterJoinTable_IncrementVenueBands() { // This test will check to see if the program can successfully write to the join table and add a connection between VENUES and BANDS // arrange Band newBand = new Band("Fire"); newBand.Save(); Venue newVenue = new Venue("Boston"); newVenue.Save(); // act newVenue.AddBand(newBand); // assert Assert.Equal(newBand, newVenue.GetBands()[0]); }
public void Delete_RemoveFromJoinTable_DecrementDatabase() { // This test will check to see if the delete functionality of the program can successfully remove items from the join table // arrange Band newBand = new Band("Fire"); newBand.Save(); Venue newVenue = new Venue("Boston"); newVenue.Save(); // act newBand.AddVenue(newVenue); newVenue.Delete(); // assert Assert.Equal(0, newBand.GetVenues().Count); }
public void SaveGetAll_ManyBands_ReturnListOfBands() { //Arrange Band bandOne = new Band("Green Day"); bandOne.Save(); Band bandTwo = new Band("Spice Girl"); bandTwo.Save(); //Act List <Band> output = Band.GetAll(); List <Band> verify = new List <Band> { bandOne, bandTwo }; //Assert Assert.Equal(verify, output); }
public void DeleteVenues_OneBand_VenueRemovedFromJoinTable() { //Arrange Band testBand = new Band("Green Day"); testBand.Save(); Venue testVenue1 = new Venue("Park"); Venue testVenue2 = new Venue("Manhattan Square"); testVenue1.Save(); testVenue2.Save(); testBand.DeleteVenues(); //Act int output = testBand.GetVenues().Count; //Assert Assert.Equal(0, output); }
public void AddBand_OneBand_BandAddedToJoinTable() { //Arrange Venue testVenue = new Venue("Manhattan Square"); testVenue.Save(); Band testBand = new Band("Green Day"); testBand.Save(); testVenue.AddBand(testBand); //Act List <Band> output = testVenue.GetBands(); List <Band> verify = new List <Band> { testBand }; //Assert Assert.Equal(verify, output); }
public void AddVenue_OneBand_VenueAddedToJoinTable() { //Arrange Band testBand = new Band("Green Day"); testBand.Save(); Venue testVenue = new Venue("Park"); testVenue.Save(); testBand.AddVenue(testVenue); //Act List <Venue> output = testBand.GetVenues(); List <Venue> verify = new List <Venue> { testVenue }; //Assert Assert.Equal(verify, output); }
public void DeleteBands_OneVenue_AllBandsRemovedFromJoinTable() { //Arrange Venue testVenue = new Venue("Park"); testVenue.Save(); Band testBand1 = new Band("Green Day"); testBand1.Save(); Band testBand2 = new Band("Spice Girl"); testBand2.Save(); testVenue.AddBand(testBand1); testVenue.AddBand(testBand2); testVenue.DeleteBands(); //Act int output = testVenue.GetBands().Count; //Assert Assert.Equal(0, output); }
public void DeleteVenue_TwoVenueRemoveOne_VenueRemovedFromJoinTable() { //Arrange Band testBand = new Band("Green Day"); testBand.Save(); Venue testVenue1 = new Venue("Park"); Venue testVenue2 = new Venue("Manhattan Square"); testVenue1.Save(); testVenue2.Save(); testBand.AddVenue(testVenue1); testBand.AddVenue(testVenue2); testBand.DeleteVenue(testVenue1); //Act List <Venue> output = testBand.GetVenues(); List <Venue> verify = new List <Venue> { testVenue2 }; //Assert Assert.Equal(verify, output); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/bands"] = _ => { return(View["bands.cshtml", ModelMaker()]); }; Post["/bands"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); newBand.AddVenue(Venue.Find(Request.Form["add-venue"])); return(View["bands.cshtml", ModelMaker()]); }; Delete["/bands"] = _ => { Band.DeleteAll(); return(View["bands.cshtml", ModelMaker()]); }; Post["/bands/search"] = _ => { List <Band> foundBand = Band.SearchName(Request.Form["search-band"]); return(View["search.cshtml", foundBand]); }; Get["/bands/{id}"] = parameters => { var foundBand = Band.Find(parameters.id); var foundBandVenues = foundBand.GetVenues(); Dictionary <string, object> model = ModelMaker(); model.Add("band", foundBand); model.Add("band-venues", foundBandVenues); return(View["band.cshtml", model]); }; Delete["/band/{id}/deleted"] = parameters => { Band foundBand = Band.Find(parameters.id); foundBand.DeleteThis(); return(View["bands.cshtml", ModelMaker()]); }; Patch["band/edit/{id}"] = parameters => { Band foundBand = Band.Find(parameters.id); foundBand.Update(Request.Form["band-name"]); var foundBandVenues = foundBand.GetVenues(); Dictionary <string, object> model = ModelMaker(); model.Add("band", foundBand); model.Add("band-venues", foundBandVenues); return(View["band.cshtml", model]); }; Patch["band/addVenue/{id}"] = parameters => { var foundBand = Band.Find(parameters.id); foundBand.AddVenue(Venue.Find(Request.Form["add-new-venue"])); var foundBandVenues = foundBand.GetVenues(); Dictionary <string, object> model = ModelMaker(); model.Add("band", foundBand); model.Add("band-venues", foundBandVenues); return(View["band.cshtml", model]); }; Delete["band/removeVenue/{id}"] = parameters => { Band foundBand = Band.Find(parameters.id); foundBand.DeleteVenue(Venue.Find(Request.Form["remove-venue"])); var foundBandVenues = foundBand.GetVenues(); Dictionary <string, object> model = ModelMaker(); model.Add("band", foundBand); model.Add("band-venues", foundBandVenues); return(View["band.cshtml", model]); }; Delete["band/removeVenues/{id}"] = parameters => { Band foundBand = Band.Find(parameters.id); foundBand.DeleteVenues(); Dictionary <string, object> model = ModelMaker(); var foundBandVenues = foundBand.GetVenues(); model.Add("band", foundBand); model.Add("band-venues", foundBandVenues); return(View["band.cshtml", model]); }; Get["/venues"] = _ => { return(View["venues.cshtml", ModelMaker()]); }; Post["/venues"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); return(View["venues.cshtml", ModelMaker()]); }; Delete["/venues"] = _ => { Band.DeleteAll(); return(View["venues.cshtml", ModelMaker()]); }; Post["/venues/search"] = _ => { List <Venue> foundVenue = Venue.SearchName(Request.Form["search-venue"]); return(View["search.cshtml", foundVenue]); }; Get["/venues/{id}"] = parameters => { var foundVenue = Venue.Find(parameters.id); var foundVenueBands = foundVenue.GetBands(); Dictionary <string, object> model = ModelMaker(); model.Add("venue", foundVenue); model.Add("venue-bands", foundVenueBands); return(View["venue.cshtml", model]); }; Delete["/venue/{id}/deleted"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.DeleteThis(); return(View["venues.cshtml", ModelMaker()]); }; Patch["venue/edit/{id}"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.Update(Request.Form["venue-name"]); var foundVenueBands = foundVenue.GetBands(); Dictionary <string, object> model = ModelMaker(); model.Add("venue", foundVenue); model.Add("venue-bands", foundVenueBands); return(View["venue.cshtml", model]); }; Patch["venue/addBand/{id}"] = parameters => { var foundVenue = Venue.Find(parameters.id); foundVenue.AddBand(Band.Find(Request.Form["add-new-band"])); var foundVenueBands = foundVenue.GetBands(); Dictionary <string, object> model = ModelMaker(); model.Add("venue", foundVenue); model.Add("venue-bands", foundVenueBands); return(View["venue.cshtml", model]); }; Delete["venue/removeBand/{id}"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.DeleteBand(Band.Find(Request.Form["remove-band"])); var foundVenueBands = foundVenue.GetBands(); Dictionary <string, object> model = ModelMaker(); model.Add("venue", foundVenue); model.Add("venue-bands", foundVenueBands); return(View["venue.cshtml", model]); }; Delete["venue/removeBands/{id}"] = parameters => { Venue foundVenue = Venue.Find(parameters.id); foundVenue.DeleteBands(); Dictionary <string, object> model = ModelMaker(); var foundVenueBands = foundVenue.GetBands(); model.Add("venue", foundVenue); model.Add("venue-bands", foundVenueBands); return(View["venue.cshtml", model]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml", ModelMaker()]); }; Post["/search"] = _ => { return(View["search.cshtml", DB.Search(Request.Form["search"])]); }; Post["/bands"] = _ => { Band newBand = new Band(Request.Form["new-band"]); newBand.Save(); return(View["index.cshtml", ModelMaker()]); }; Post["/venues"] = _ => { Venue newVenue = new Venue(Request.Form["new-venue"]); newVenue.Save(); return(View["index.cshtml", ModelMaker()]); }; Get["/bands/{id}"] = parameters => { Dictionary <string, object> model = ModelMaker(); model.Add("band", Band.Find(parameters.id)); return(View["band.cshtml", model]); }; Get["/venues/{id}"] = parameters => { Dictionary <string, object> model = ModelMaker(); model.Add("venue", Venue.Find(parameters.id)); return(View["venue.cshtml", model]); }; Patch["/venues/{id}"] = parameters => { Venue targetVenue = Venue.Find(parameters.id); targetVenue.Update(Request.Form["update-venue"]); Dictionary <string, object> model = ModelMaker(); model.Add("venue", targetVenue); return(View["venue.cshtml", model]); }; Delete["/venues/{id}"] = parameters => { Venue.Find(parameters.id).Delete(); return(View["index.cshtml", ModelMaker()]); }; Post["/venue_bands/{id}"] = parameters => { Venue newVenue = Venue.Find(parameters.id); newVenue.AddBand(Band.Find(Request.Form["add-band"])); Dictionary <string, object> model = ModelMaker(); model.Add("venue", newVenue); return(View["venue.cshtml", model]); }; Post["/band_venues/{id}"] = parameters => { Band newBand = Band.Find(parameters.id); newBand.AddVenue(Venue.Find(Request.Form["add-venue"])); Dictionary <string, object> model = ModelMaker(); model.Add("band", newBand); return(View["band.cshtml", model]); }; }