예제 #1
0
 public void T5_Find_FindNameInDatabase()
 {
     //arrange
       Band testBand = new Band("Pheonix");
       testBand.Save();
       //act
       Band foundBand = Band.Find(testBand.GetId());
       //Assert
       Assert.Equal(testBand, foundBand);
 }
예제 #2
0
        public void T5_Find_FindNameInDatabase()
        {
            //arrange
            Band testBand = new Band("Pheonix");

            testBand.Save();
            //act
            Band foundBand = Band.Find(testBand.GetId());

            //Assert
            Assert.Equal(testBand, foundBand);
        }
예제 #3
0
        public void T4_Save_AsignsIdToObject()
        {
            //arrange
              Band newBand = new Band("GNR");
              //action
              newBand.Save();
              Band savedBand = Band.GetAll()[0];

              int result = savedBand.GetId();
              int testId = newBand.GetId();
              //assert
              Assert.Equal(testId, result);
        }
예제 #4
0
 public override bool Equals(System.Object otherBand)
 {
     if (!(otherBand is Band))
     {
         return(false);
     }
     else
     {
         Band newBand      = (Band)otherBand;
         bool idEquality   = (this.GetId() == newBand.GetId());
         bool nameEquality = (this.GetName() == newBand.GetName());
         return(idEquality && nameEquality);
     }
 }
예제 #5
0
        public void T4_Save_AsignsIdToObject()
        {
            //arrange
            Band newBand = new Band("GNR");

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

            int result = savedBand.GetId();
            int testId = newBand.GetId();

            //assert
            Assert.Equal(testId, result);
        }
예제 #6
0
        public void AddBands(Band newBand)
        {
            SqlConnection conn = DB.Connection();
              conn.Open();

              SqlCommand cmd = new SqlCommand("INSERT INTO venues_bands (band_id, venue_id) VALUES (@BandId,@VenueId)",conn);

              SqlParameter bandIdParameter = new SqlParameter();
              bandIdParameter.ParameterName= "@BandId";
              bandIdParameter.Value= newBand.GetId();

              SqlParameter venueIdParameter = new SqlParameter();
              venueIdParameter.ParameterName= "@VenueId";
              venueIdParameter.Value= this.GetId();

              cmd.Parameters.Add(bandIdParameter);
              cmd.Parameters.Add(venueIdParameter);

              cmd.ExecuteNonQuery();

              if(conn != null)
              {
            conn.Close();
              }
        }