Exemplo n.º 1
0
        public void Venue_Update_UpdateDatabaseAndLocalObject()
        {
            Venue testVenue = new Venue("Manhattan Square");

            testVenue.Save();

            testVenue.Update("Central Park");
            Venue expectedVenue = new Venue("Central Park", testVenue.GetId());

            Assert.Equal(expectedVenue, Venue.Find(testVenue.GetId()));
        }
Exemplo n.º 2
0
        public void AddVenue(Venue newVenue)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"INSERT INTO bands_venues (band_id,  venue_id) VALUES (@BandId, @VenueId);";

            MySqlParameter venue_id = new MySqlParameter();

            venue_id.ParameterName = "@VenueId";
            venue_id.Value         = newVenue.GetId();
            cmd.Parameters.Add(venue_id);

            MySqlParameter band_id = new MySqlParameter();

            band_id.ParameterName = "@BandId";
            band_id.Value         = _id;
            cmd.Parameters.Add(band_id);

            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
Exemplo n.º 3
0
        public void Update_AlterDatabaseEntry_ReturnNewVenue()
        {
            // This test will check to see if the Venue.Update() method writes new values to the database and the returns the altered object to the local instance
            // arrange
            Venue newVenue = new Venue("Fire");

            newVenue.Save();

            Venue otherVenue = new Venue("Water");

            // act
            newVenue.Update("Water");
            otherVenue.SetId(newVenue.GetId());

            // assert
            Assert.Equal(otherVenue, Venue.Find(newVenue.GetId()));
        }
Exemplo n.º 4
0
        public void Find_OneVenueId_ReturnVenueFromDatabase()
        {
            //Arrange
            Venue testVenue = new Venue("Manhattan Square");

            testVenue.Save();

            //Act
            Venue foundVenue = Venue.Find(testVenue.GetId());

            //Assert
            Assert.Equal(testVenue, foundVenue);
        }
Exemplo n.º 5
0
        public void DeleteVenue(Venue newVenue)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();
            SqlCommand cmd = new SqlCommand("DELETE FROM bands_venues WHERE venue_id = @VenueId AND band_id = @BandId;", conn);

            cmd.Parameters.Add(new SqlParameter("@VenueId", newVenue.GetId().ToString()));
            cmd.Parameters.Add(new SqlParameter("@BandId", this.GetId().ToString()));
            cmd.ExecuteNonQuery();

            DB.CloseSqlConnection(conn);
        }
Exemplo n.º 6
0
        public void AddVenue(Venue newVenue)
        {
            SqlConnection conn = DB.Connection();

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

            cmd.Parameters.Add(new SqlParameter("@VenueId", newVenue.GetId().ToString()));
            cmd.Parameters.Add(new SqlParameter("@BandId", this.GetId().ToString()));
            cmd.ExecuteNonQuery();

            DB.CloseSqlConnection(conn);
        }
Exemplo n.º 7
0
 public override bool Equals(System.Object randomVenue)
 {
     if (!(randomVenue is Venue))
     {
         return(false);
     }
     else
     {
         Venue newVenue     = (Venue)randomVenue;
         bool  idEquality   = (this.GetId() == newVenue.GetId());
         bool  nameEquality = (this.GetName() == newVenue.GetName());
         return(idEquality && nameEquality);
     }
 }
Exemplo n.º 8
0
        public void Find_GetObjectFromDatabase_ReturnVenue()
        {
            // This test will check to see if the programs Venue.Find() method can get a venue object from the database and return it
            // arrange
            Venue newVenue = new Venue("Fire");

            newVenue.Save();

            // act
            Venue foundVenue = Venue.Find(newVenue.GetId());

            // assert
            Assert.Equal(newVenue, foundVenue);
        }
Exemplo n.º 9
0
        public void Save_OneVenue_VenueSavedWithCorrectID()
        {
            //Arrange
            Venue testVenue = new Venue("Manhattan Square");

            testVenue.Save();
            Venue savedVenue = Venue.GetAll()[0];

            //Act
            int output = savedVenue.GetId();
            int verify = testVenue.GetId();

            //Assert
            Assert.Equal(verify, output);
        }
Exemplo n.º 10
0
        public void AddVenue(Venue newVenue)
        {
            // This function will add a connection between the BAND and the VENUE in the join table
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand cmd = new SqlCommand("DELETE FROM bands_venues WHERE band_id = @NewBandId AND venue_id = @NewVenueId; INSERT INTO bands_venues (band_id, venue_id) VALUES (@NewBandId, @NewVenueId);", conn);

            cmd.Parameters.Add(new SqlParameter("@NewBandId", this.GetId()));
            cmd.Parameters.Add(new SqlParameter("@NewVenueId", newVenue.GetId()));

            cmd.ExecuteNonQuery();

            DB.CloseSqlConnection(conn);
        }
Exemplo n.º 11
0
        public override bool Equals(System.Object otherVenue)
        {
            if (!(otherVenue is Venue))
            {
                return(false);
            }
            else
            {
                Venue newVenue          = (Venue)otherVenue;
                bool  idEquality        = this.GetId() == newVenue.GetId();
                bool  nameEquality      = this.GetName() == newVenue.GetName();
                bool  contactEquality   = this.GetContact() == newVenue.GetContact();
                bool  addressEquality   = this.GetAddress() == newVenue.GetAddress();
                bool  eventDateEquality = this.GetEventDate() == newVenue.GetEventDate();

                return(idEquality && nameEquality && eventDateEquality && contactEquality && addressEquality);
            }
        }