Ejemplo n.º 1
0
        public void DeleteBand_TwoBandRemoveOne_BandRemovedFromJoinTable()
        {
            //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.DeleteBand(testBand2);


            //Act
            List <Band> output = testVenue.GetBands();
            List <Band> verify = new List <Band> {
                testBand1
            };

            //Assert
            Assert.Equal(verify, output);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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]);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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]);
            };
        }