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); }
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); }
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); } }
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(); } }