public void T8_GetBands_RetrievesAllVenueBands() { Venue testVenue = new Venue("Paramount Theatre"); testVenue.Save(); Band testBand1 = new Band("Brand New"); testBand1.Save(); Band testBand2 = new Band("A Little Old"); testBand2.Save(); DateTime performanceDate1 = new DateTime(2016, 08, 04); DateTime performanceDate2 = new DateTime(2016, 09, 20); Performance newPerformance1 = new Performance(testVenue.GetId(), testBand1.GetId(), performanceDate1); newPerformance1.Save(); Performance newPerformance2 = new Performance(testVenue.GetId(), testBand2.GetId(), performanceDate2); newPerformance2.Save(); List <Band> testBands = new List <Band> { testBand1, testBand2 }; List <Band> result = testVenue.GetBands(); Assert.Equal(testBands, result); }
public void T6_GetVenues_RetrievesAllBandVenues() { Band testBand = new Band("Brand New"); testBand.Save(); Venue testVenue1 = new Venue("Paramount Theatre"); testVenue1.Save(); Venue testVenue2 = new Venue("Epicodus Classroom"); testVenue2.Save(); DateTime performanceDate1 = new DateTime(2016, 08, 04); DateTime performanceDate2 = new DateTime(2016, 09, 20); Performance newPerformance1 = new Performance(testVenue1.GetId(), testBand.GetId(), performanceDate1); newPerformance1.Save(); Performance newPerformance2 = new Performance(testVenue2.GetId(), testBand.GetId(), performanceDate2); newPerformance2.Save(); List <Venue> testVenues = new List <Venue> { testVenue1, testVenue2 }; List <Venue> result = testBand.GetVenues(); Assert.Equal(testVenues, result); }
public void T5_Find_FindsPerformanceInDB() { DateTime performanceDate = new DateTime(2016, 08, 04); Performance testPerformance = new Performance(1, 2, performanceDate); testPerformance.Save(); Performance foundPerformance = Performance.Find(testPerformance.GetId()); Assert.Equal(testPerformance, foundPerformance); }
public void T4_Save_AssignsIdToPerformance() { DateTime performanceDate = new DateTime(2016, 08, 04); Performance testPerformance = new Performance(1, 2, performanceDate); testPerformance.Save(); Performance savedPerformance = Performance.GetAll()[0]; int result = savedPerformance.GetId(); int testId = testPerformance.GetId(); Assert.Equal(testId, result); }
public void T6_GetBandName_GetsPerformanceBandName() { Band testBand = new Band("Brand New"); testBand.Save(); DateTime performanceDate = new DateTime(2016, 08, 04); Performance testPerformance = new Performance(1, testBand.GetId(), performanceDate); testPerformance.Save(); string result = testPerformance.GetBandName(); Assert.Equal("Brand New", result); }
public void T3_Save_SavesToDB() { DateTime performanceDate = new DateTime(2016, 08, 04); Performance testPerformance = new Performance(1, 2, performanceDate); testPerformance.Save(); List <Performance> result = Performance.GetAll(); List <Performance> testList = new List <Performance> { testPerformance }; Assert.Equal(testList, result); }
public void T7_GetVenueName_GetsPerformanceVenueName() { Venue testVenue = new Venue("Paramount Theatre"); testVenue.Save(); DateTime performanceDate = new DateTime(2016, 08, 04); Performance testPerformance = new Performance(testVenue.GetId(), 1, performanceDate); testPerformance.Save(); string result = testPerformance.GetVenueName(); Assert.Equal("Paramount Theatre", result); }
public void T9_DeleteAssociations_DeletesAssociationsFromJoin() { Venue testVenue = new Venue("Paramount Theatre"); testVenue.Save(); Band testBand = new Band("Brand New"); testBand.Save(); DateTime performanceDate = new DateTime(2016, 08, 04); Performance newPerformance = new Performance(testVenue.GetId(), testBand.GetId(), performanceDate); newPerformance.Save(); testVenue.DeleteAssociations(); int result = Performance.GetAll().Count; Assert.Equal(0, result); }
public HomeModule() { Get["/"] = _ => { Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Post["/band_added"] = _ => { Band newBand = new Band(Request.Form["band-name"]); newBand.Save(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Post["/venue_added"] = _ => { Venue newVenue = new Venue(Request.Form["venue-name"]); newVenue.Save(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Get["/band/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Band selectedBand = Band.Find(parameters.id); List <Venue> bandVenues = selectedBand.GetVenues(); model.Add("band", selectedBand); model.Add("venues", bandVenues); return(View["band.cshtml", model]); }; Get["/venue/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue selectedVenue = Venue.Find(parameters.id); List <Band> venueBands = selectedVenue.GetBands(); model.Add("venue", selectedVenue); model.Add("bands", venueBands); return(View["venue.cshtml", model]); }; Patch["/venue/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.Update(Request.Form["rename"]); List <Band> venueBands = selectedVenue.GetBands(); model.Add("venue", selectedVenue); model.Add("bands", venueBands); return(View["venue.cshtml", model]); }; Delete["/deleted/{id}"] = parameters => { Venue selectedVenue = Venue.Find(parameters.id); selectedVenue.DeleteAssociations(); selectedVenue.Delete(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Post["/performance_added"] = _ => { Performance newPerformance = new Performance(Request.Form["performance-venue"], Request.Form["performance-band"], Request.Form["performance-date"]); newPerformance.Save(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; Delete["/delete_all"] = _ => { Venue.DeleteAll(); Band.DeleteAll(); Performance.DeleteAll(); Dictionary <string, object> model = new Dictionary <string, object>(); List <Venue> allVenues = Venue.GetAll(); List <Band> allBands = Band.GetAll(); List <Performance> allPerformances = Performance.GetAll(); model.Add("venues", allVenues); model.Add("bands", allBands); model.Add("performances", allPerformances); return(View["index.cshtml", model]); }; }