public void Test_DeleteOne_DeletesASpecificVenueObject()
        {
            //Arrange
              Venue firstVenue = new Venue("Chad's");
              firstVenue.Save();
              Venue secondVenue = new Venue("Todd's");
              secondVenue.Save();

              //Act
              secondVenue.Delete();
              List<Venue> expectedVenue = new List<Venue> {firstVenue};
              List<Venue> testVenue= Venue.GetAll();

              //Assert
              Assert.Equal(expectedVenue, testVenue);
        }
Esempio n. 2
0
        public void Delete_RemoveVenueFromDatabase_VenueId()
        {
            Venue newVenue = new Venue("The Filmore");

            newVenue.Save();
            Venue testVenue = new Venue("Cornell University");

            testVenue.Save();

            newVenue.Delete();
            List <Venue> oneDeleted = Venue.GetAll();
            List <Venue> oneLiteral = new List <Venue> {
                testVenue
            };

            Assert.Equal(oneDeleted, oneLiteral);
        }
Esempio n. 3
0
        public void Venue_Delete_DeletesSingleVenue()
        {
            Venue venue1 = new Venue("The Overlook", "123 1st Street");

            venue1.Save();
            Venue venue2 = new Venue("Wonder Ballroom", "128 NE Russell St");

            venue2.Save();

            venue1.Delete();

            List <Venue> testList    = Venue.GetAll();
            List <Venue> controlList = new List <Venue> {
                venue2
            };

            Assert.Equal(controlList, testList);
        }
        public void Delete_ForVenue_DeletesRowFromTable()
        {
            //Arrange
            Venue firstVenue  = new Venue("The Station");
            Venue secondVenue = new Venue("Club Fiber");
            Venue thirdVenue  = new Venue("H20");

            firstVenue.Save();
            secondVenue.Save();
            thirdVenue.Save();

            //Act
            firstVenue.Delete();

            //Assert
            List <Venue> actualResult   = Venue.GetAll();
            List <Venue> expectedResult = new List <Venue> {
                secondVenue, thirdVenue
            };

            Assert.Equal(expectedResult, actualResult);
        }
Esempio n. 5
0
        public void Test_Delete_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            Venue firstTestVenue = new Venue("Madison Square Garden", "NYC");

            firstTestVenue.Save();
            Venue secondTestVenue = new Venue("Crystal Ballroom", "Portland, OR");

            secondTestVenue.Save();
            Venue thirdTestVenue = new Venue("Someone's Basement", "Anytown, USA");

            thirdTestVenue.Save();
            List <Venue> expectedList = new List <Venue> {
                firstTestVenue, secondTestVenue
            };

            //Act
            thirdTestVenue.Delete();
            List <Venue> resultList = Venue.GetAll();

            //Assert
            Assert.Equal(resultList, expectedList);
        }
 public HomeModule()
 {
     Get["/"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         model.Add("listBands", Band.GetAll());
         model.Add("listVenues", Venue.GetAll());
         model.Add("show-info", null);
         return(View["index.cshtml", model]);
     }; //homepage with lists of venues/bands, buttons to add venue/band
     Get["/bands/new"] = _ => {
         Dictionary <string, string> model = new Dictionary <string, string> {
         };
         model.Add("form-type", "new-band");
         return(View["form.cshtml", model]);
     }; //returns form to add new band
     Post["/bands/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Band band = new Band(Request.Form["band-name"]);
         band.Save();
         model.Add("listBands", Band.GetAll());
         model.Add("listVenues", Venue.GetAll());
         model.Add("newBand", band);
         model.Add("show-info", "new-band-info");
         return(View["index.cshtml", model]);
     }; //posts from form adding new band
     Get["/venues/new"] = _ => {
         Dictionary <string, string> model = new Dictionary <string, string> {
         };
         model.Add("form-type", "new-venue");
         return(View["form.cshtml", model]);
     }; //returns form to add new venue
     Post["/venues/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Venue venue = new Venue(Request.Form["venue-name"], Request.Form["venue-city"]);
         venue.Save();
         model.Add("listBands", Band.GetAll());
         model.Add("listVenues", Venue.GetAll());
         model.Add("newVenue", venue);
         model.Add("show-info", "new-venue-info");
         return(View["index.cshtml", model]);
     }; //posts from form adding new venue
     Get["/bands/{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]);
     }; //retrieves individual band pages
     Get["/venues/{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]);
     }; //retrieves individual venue pages
     Get["/band/{id}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Band   selectedBand = Band.Find(parameters.id);
         string bandEdit     = Request.Query["band-edit"];
         model.Add("form-type", bandEdit);
         model.Add("band", selectedBand);
         return(View["edit.cshtml", model]);
     }; //edit individual band
     Patch["/band/{id}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Band selectedBand = Band.Find(parameters.id);
         selectedBand.UpdateBand(Request.Form["band-name"]);
         List <Venue> bandVenues = selectedBand.GetVenues();
         model.Add("band", selectedBand);
         model.Add("venues", bandVenues);
         return(View["band.cshtml", model]);
     }; //returns edited band page
     Get["/band/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Band   selectedBand = Band.Find(parameters.id);
         string bandDelete   = Request.Query["band-delete"];
         model.Add("form-type", bandDelete);
         model.Add("band", selectedBand);
         return(View["delete.cshtml", model]);
     }; //delete individual band
     Delete["/band/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Band selectedBand = Band.Find(parameters.id);
         selectedBand.Delete();
         model.Add("listBands", Band.GetAll());
         model.Add("listVenues", Venue.GetAll());
         model.Add("show-info", null);
         return(View["index.cshtml", model]);
     }; //returns confirmation of deleted band
     Get["/venue/{id}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Venue  selectedVenue = Venue.Find(parameters.id);
         string venueEdit     = Request.Query["venue-edit"];
         model.Add("form-type", venueEdit);
         model.Add("venue", selectedVenue);
         return(View["edit.cshtml", model]);
     }; //edit individual venue
     Patch["/venue/{id}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Venue selectedVenue = Venue.Find(parameters.id);
         selectedVenue.UpdateVenue(Request.Form["venue-name"], Request.Form["venue-city"]);
         List <Band> venueBands = selectedVenue.GetBands();
         model.Add("venue", selectedVenue);
         model.Add("bands", venueBands);
         return(View["venue.cshtml", model]);
     }; //returns edited venue page
     Get["/venue/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Venue  selectedVenue = Venue.Find(parameters.id);
         string venueDelete   = Request.Query["venue-delete"];
         model.Add("form-type", venueDelete);
         model.Add("venue", selectedVenue);
         return(View["delete.cshtml", model]);
     }; //delete individual venue
     Delete["/venue/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Venue selectedVenue = Venue.Find(parameters.id);
         selectedVenue.Delete();
         model.Add("listBands", Band.GetAll());
         model.Add("listVenues", Venue.GetAll());
         model.Add("show-info", null);
         return(View["index.cshtml", model]);
     }; //returns confirmation of deleted venue
     Get["/venues/{id}/bands/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Venue selectedVenue = Venue.Find(parameters.id);
         model.Add("venue", selectedVenue);
         model.Add("listBands", Band.GetAll());
         return(View["add_band.cshtml", model]);
     }; //navigates to form to add band to venue
     Post["/venues/{id}/bands/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Venue selectedVenue = Venue.Find(parameters.id);
         Band  selectedBand  = Band.Find(Request.Form["add-band"]);
         selectedVenue.AddBand(selectedBand);
         model.Add("venue", selectedVenue);
         model.Add("bands", selectedVenue.GetBands());
         return(View["venue.cshtml", model]);
     }; //posts from form adding band to venue
     Get["/bands/{id}/venues/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Band selectedBand = Band.Find(parameters.id);
         model.Add("band", selectedBand);
         model.Add("listVenues", Venue.GetAll());
         return(View["add_venue.cshtml", model]);
     }; //navigates to form to add venue to band
     Post["/bands/{id}/venues/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Band  selectedBand  = Band.Find(parameters.id);
         Venue selectedVenue = Venue.Find(Request.Form["add-venue"]);
         selectedBand.AddVenue(selectedVenue);
         model.Add("band", selectedBand);
         model.Add("venues", selectedBand.GetVenues());
         return(View["band.cshtml", model]);
     }; //posts from form adding venue to band
 }