public void Band_Update_UpdatesBand()
        {
            Band firstBand = new Band("Ween");
              firstBand.Save();

              firstBand.Update("Dexy's Midnight Runners");

              Band resultBand = Band.Find(firstBand.GetId());

              Assert.Equal("Dexy's Midnight Runners", resultBand.GetName());
        }
        public void Save_ForBand_AssignsDatabaseId()
        {
            //Arrange
            Band testBand = new Band("Pajama Funnel");

            //Act
            testBand.Save();
            Band savedBand = Band.GetAll()[0];

            //Assert
            Assert.Equal(testBand, savedBand);
        }
        public void Find_ForBand_FindsBandInDatabase()
        {
            //Arrange
            Band testBand = new Band("Pajama Funnel");

            testBand.Save();

            //Act, Assert
            Band foundBand = Band.Find(testBand.GetId());

            Assert.Equal(testBand, foundBand);
        }
        public void Test_Find_FindsBandInDatabase()
        {
            //Arrange
            Band testBand = new Band("Modest Mouse");

            testBand.Save();
            //Act
            Band foundBand = Band.Find(testBand.Id);

            //Assert
            Assert.Equal(testBand, foundBand);
        }
Exemple #5
0
        public void Find_FindsBandInDatabase_Band()
        {
            //Arrange
            Band testBand = new Band("The Beatles");

            testBand.Save();

            //Act
            Band foundBand = Band.Find(testBand.GetId());

            //Assert
            Assert.Equal(testBand, foundBand);
        }
Exemple #6
0
        public void Save_NewBandSavesToDatabase_BandList()
        {
            Band testBand = new Band("Grateful Dead");

            testBand.Save();

            List <Band> savedBands = Band.GetAll();
            List <Band> testBands  = new List <Band> {
                testBand
            };

            Assert.Equal(savedBands, testBands);
        }
        public void Test_UpdateBand_ReturnsTrueIfBandInfoIsTheSame()
        {
            //Arrange
            Band firstTestBand = new Band("Modest Mouse");

            firstTestBand.Save();
            Band secondTestBand = new Band("Rilo Kiley", firstTestBand.Id);

            //Act
            secondTestBand.UpdateBand("Modest Mouse");
            //Assert
            Assert.Equal(firstTestBand, secondTestBand);
        }
Exemple #8
0
        public void Save_AssignsIdToNewBandObject_BandId()
        {
            Band savedBand = new Band("Grateful Dead");

            savedBand.Save();

            Band testBand = Band.GetAll()[0];

            int savedId = savedBand.GetId();
            int testId  = testBand.GetId();

            Assert.Equal(savedId, testId);
        }
        public void Save_ForBand_SavesToDatabase()
        {
            //Arrange
            Band newBand = new Band("Pajama Funnel");

            //Act
            newBand.Save();

            //Assert
            List <Band> actualResult   = Band.GetAll();
            List <Band> expectedResult = new List <Band> {
                newBand
            };
        }
        public void Test_Save_AssignsIdToBandInDatabase()
        {
            //Arrange
            Band testBand = new Band("MOdest Mouse");

            testBand.Save();
            //Act
            Band savedBand  = Band.GetAll()[0];
            int  testId     = testBand.Id;
            int  expectedId = savedBand.Id;

            //Assert
            Assert.Equal(testId, expectedId);
        }
Exemple #11
0
        public void Save_AssignIdtoObject_int()
        {
            //Arrange
            Band testBand = new Band("The Beatles");

            //Act
            testBand.Save();
            Band savedBand = Band.GetAll()[0];

            //Assert
            int actualResult   = savedBand.GetId();
            int expectedResult = testBand.GetId();

            Assert.Equal(expectedResult, actualResult);
        }
        public void Test_Save_SavesBandToDatabase()
        {
            //Arrange
            Band testBand = new Band("Modest Mouse");

            testBand.Save();
            //Act
            List <Band> result         = Band.GetAll();
            List <Band> expectedResult = new List <Band> {
                testBand
            };

            //Assert
            Assert.Equal(result, expectedResult);
        }
        public void Test_DeleteOne_DeletesASpecificBandObject()
        {
            //Arrange
              Band firstBand = new Band("Ween");
              firstBand.Save();
              Band secondBand = new Band("Dexy's Midnight Runners");
              secondBand.Save();

              //Act
              secondBand.Delete();
              List<Band> expectedBand = new List<Band> {firstBand};
              List<Band> testBand= Band.GetAll();

              //Assert
              Assert.Equal(expectedBand, testBand);
        }
Exemple #14
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            Band newBand = new Band("The Beatles");

            //Act
            newBand.Save();

            //Assert
            List <Band> actualResult   = Band.GetAll();
            List <Band> expectedResult = new List <Band> {
                newBand
            };

            Assert.Equal(expectedResult, actualResult);
        }
        public void Test_AddShow_AddsAShowWithBandAndVenue()
        {
            //Arrange
              Band testBand = new Band("Ween");
              testBand.Save();
              Venue testVenue = new Venue("Chad's");
              testVenue.Save();

              //Act
              testVenue.AddShow(testBand.GetId(), testDate);
              List<Venue> expectedVenue = new List<Venue> {testVenue};
              List<Venue> result= testBand.GetVenues();

              //Assert
              Assert.Equal(expectedVenue, result);
        }
        public void GetAll_ForMultipleBands_ReturnsListWithAllBands()
        {
            //Arrange
            Band firstBand  = new Band("Pajama Funnel");
            Band secondBand = new Band("Allergy of Warm");

            firstBand.Save();
            secondBand.Save();

            //Act, Assert
            List <Band> actualResult   = Band.GetAll();
            List <Band> expectedResult = new List <Band> {
                secondBand, firstBand
            };

            Assert.Equal(expectedResult, actualResult);
        }
        public void Band_AddVenue_CreatesRelationShipInDB()
        {
            Band band = new Band("The Beatles", 4);

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

            venue.Save();

            band.AddVenue(venue);

            List <Venue> testList    = band.GetVenues();
            List <Venue> controlList = new List <Venue> {
                venue
            };

            Assert.Equal(controlList, testList);
        }
        public void Band_Delete_DeletesSingleBand()
        {
            Band band1 = new Band("The Beatles", 4);

            band1.Save();
            Band band2 = new Band("Phantogram", 2);

            band2.Save();

            band1.Delete();

            List <Band> testList    = Band.GetAll();
            List <Band> controlList = new List <Band> {
                band2
            };

            Assert.Equal(controlList, testList);
        }
Exemple #19
0
        public void Venue_AddBand_CreatesRelationShipInDB()
        {
            Band band = new Band("The Beatles", 4);

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

            venue.Save();

            venue.AddBand(band);

            List <Band> testList    = venue.GetBands();
            List <Band> controlList = new List <Band> {
                band
            };

            Assert.Equal(controlList, testList);
        }
Exemple #20
0
        public void GetAll_AllBands_ReturnsListOfBands()
        {
            //Arrange
            Band firstBand  = new Band("The Beatles");
            Band secondBand = new Band("Madonna");

            //Act
            firstBand.Save();
            secondBand.Save();

            //Assert
            List <Band> actualResult   = Band.GetAll();
            List <Band> expectedResult = new List <Band> {
                firstBand, secondBand
            };

            Assert.Equal(expectedResult, actualResult);
        }
        public void Test_AddBand_AddBandToVenue()
        {
            //Arrange
            Band newBand = new Band("Modest Mouse");

            newBand.Save();
            Venue testVenue = new Venue("Madison Square Garden", "NYC");

            testVenue.Save();
            //Act
            testVenue.AddBand(newBand);
            List <Band> testVenueBands = testVenue.GetBands();
            List <Band> expectedList   = new List <Band> {
                newBand
            };

            //Assert
            Assert.Equal(expectedList, testVenueBands);
        }
        public void Test_AddVenue_AddVenueToBand()
        {
            //Arrange
            Venue newVenue = new Venue("Madison Square Garden", "NYC");

            newVenue.Save();
            Band testBand = new Band("Modest Mouse");

            testBand.Save();
            //Act
            testBand.AddVenue(newVenue);
            List <Venue> testBandVenues = testBand.GetVenues();
            List <Venue> expectedList   = new List <Venue> {
                newVenue
            };

            //Assert
            Assert.Equal(expectedList, testBandVenues);
        }
Exemple #23
0
        public void AddBand_ForRowAddedToJoinTable_Row()
        {
            //Arrange
            Venue testVenue = new Venue("Madison Square Garden");

            testVenue.Save();
            Band testBand = new Band("The Beatles");

            testBand.Save();

            //Act
            testVenue.AddBand(testBand);

            //Assert
            List <Band> actualResult   = testVenue.GetBands();
            List <Band> expectedResult = new List <Band> {
                testBand
            };

            Assert.Equal(expectedResult, actualResult);
        }
Exemple #24
0
        public void AddVenue_ForRowAddedToJoinTable_Row()
        {
            //Arrange
            Band testBand = new Band("The Beatles");

            testBand.Save();
            Venue testVenue = new Venue("Madison Square Garden");

            testVenue.Save();

            //Act
            testBand.AddVenue(testVenue);

            //Assert
            List <Venue> actualResult   = testBand.GetVenues();
            List <Venue> expectedResult = new List <Venue> {
                testVenue
            };

            Assert.Equal(expectedResult, actualResult);
        }
        public void Band_GetMembers_ReturnsListOfMembers()
        {
            Band band = new Band("The Beatles", 4);

            band.Save();
            Band band2 = new Band("Phantogram", 2);

            band2.Save();

            Member member1 = new Member("John", band.Id);
            Member member2 = new Member("Tom", band2.Id);

            member1.Save();
            member2.Save();

            List <Member> testList    = band.GetMembers();
            List <Member> controlList = new List <Member> {
                member1
            };

            Assert.Equal(controlList, testList);
        }
        public void AddBand_ForVenueAndBand_AddsRowToJoinTable()
        {
            //Arrange
            Venue testVenue = new Venue("The Station");

            testVenue.Save();

            Band testBand = new Band("Pajama Funnel");

            testBand.Save();

            //Act
            testVenue.AddBand(testBand);

            //Assert
            List <Band> actualResult   = testVenue.GetBands();
            List <Band> expectedResult = new List <Band> {
                testBand
            };

            Assert.Equal(expectedResult, actualResult);
        }
Exemple #27
0
        public void Venue_DeleteBandRelationship_DeletesRelationship()
        {
            Venue venue = new Venue("The Overlook", "123 1st Street");

            venue.Save();
            Band band1 = new Band("The Beatles", 4);

            band1.Save();
            Band band2 = new Band("Phantogram", 2);

            band2.Save();

            venue.AddBand(band1);
            venue.AddBand(band2);
            venue.DeleteBandRelationship(band1);

            List <Band> testList    = venue.GetBands();
            List <Band> controlList = new List <Band> {
                band2
            };

            Assert.Equal(controlList, testList);
        }
        public void Test_Delete_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            Band firstTestBand = new Band("Modest Mouse");

            firstTestBand.Save();
            Band secondTestBand = new Band("Rilo Kiley");

            secondTestBand.Save();
            Band thirdTestBand = new Band("Pink Floyd");

            thirdTestBand.Save();
            List <Band> expectedList = new List <Band> {
                firstTestBand, secondTestBand
            };

            //Act
            thirdTestBand.Delete();
            List <Band> resultList = Band.GetAll();

            //Assert
            Assert.Equal(resultList, expectedList);
        }
        public void Test_DeleteBandFromVenue()
        {
            //Arrange
            Venue newVenue = new Venue("Madison Square Garden", "NYC");

            newVenue.Save();
            Band firstTestBand = new Band("Modest Mouse");

            firstTestBand.Save();
            newVenue.AddBand(firstTestBand);
            Band secondTestBand = new Band("Rilo Kiley");

            secondTestBand.Save();
            newVenue.AddBand(secondTestBand);
            //Act
            newVenue.DeleteBandFromVenue(secondTestBand);
            List <Band> resultList   = newVenue.GetBands();
            List <Band> expectedList = new List <Band> {
                firstTestBand
            };

            //Assert
            Assert.Equal(expectedList, resultList);
        }
Exemple #30
0
        public void AddBand_AddsBandToVenue_BandList()
        {
            Venue newVenue = new Venue("The Filmore");

            newVenue.Save();

            Band testBand1 = new Band("Grateful Dead");

            testBand1.Save();

            Band testBand2 = new Band("Jerry Garcia Band");

            testBand2.Save();

            newVenue.AddBand(testBand1);
            newVenue.AddBand(testBand2);

            List <Band> savedBands = newVenue.GetBands();
            List <Band> testBands  = new List <Band> {
                testBand1, testBand2
            };

            Assert.Equal(savedBands, testBands);
        }
Exemple #31
0
        public void AddVenue_AddsVenueToBand_VenueList()
        {
            Band newBand = new Band("Grateful Dead");

            newBand.Save();

            Venue testVenue1 = new Venue("The Filmore");

            testVenue1.Save();

            Venue testVenue2 = new Venue("Cornell University");

            testVenue2.Save();

            newBand.AddVenue(testVenue1);
            newBand.AddVenue(testVenue2);

            List <Venue> savedVenues = newBand.GetVenues();
            List <Venue> testVenues  = new List <Venue> {
                testVenue1, testVenue2
            };

            Assert.Equal(savedVenues, testVenues);
        }
Exemple #32
0
        public void GetVenues_ReturnAllVenuesFromBand_VenueList()
        {
            Band newBand = new Band("Grateful Dead");

            newBand.Save();

            Venue testVenue1 = new Venue("The Filmore");

            testVenue1.Save();

            Venue testVenue2 = new Venue("Cornell University");

            testVenue2.Save();

            newBand.AddVenue(testVenue1);
            newBand.AddVenue(testVenue2);

            List <Venue> savedVenue = newBand.GetVenues();
            List <Venue> testVenue  = new List <Venue> {
                testVenue1, testVenue2
            };

            Assert.Equal(savedVenue, testVenue);
        }
 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
 }
        public void Test_Find_ReturnsASpecificBandObject()
        {
            //Arrange
              Band newBand = new Band("Ween");
              newBand.Save();

              //Act
              Band foundBand = Band.Find(newBand.GetId());

              //Assert
              Assert.Equal(newBand, foundBand);
        }
        public void Test_Save_SavesCorrectObjectToDatabase()
        {
            //Arrange
              Band newBand = new Band("Ween");

              //Act
              newBand.Save();
              Band savedBand = Band.GetAll()[0];

              //Assert
              Assert.Equal(newBand, savedBand);
        }