public void Append_SelectAll_City_UnitTest() { Database database = new Database(); City city1 = new City("Milwaukee", "WI", "MKE-WI"); City city2 = new City("Waukesha", "WI", "WAU-WI"); database.Append(city1); database.Append(city2); List<City> cityList = database.SelectAllCity(); Assert.AreSame(cityList[0], city1); Assert.AreSame(cityList[1], city2); Assert.AreEqual(cityList[0].ID, "MKE-WI"); }
private void button1_Click(object sender, EventArgs e) { try { List <string> existingIDList = new List <string>(); foreach (City city in database.SelectAllCity()) { existingIDList.Add(city.ID); } string cityName = textBox8.Text; string state = textBox7.Text; string ID = textBox1.Text; if (!existingIDList.Contains(ID)) { if (cityName != "" & cityName != null & state != "" & state != null & ID != "" & ID != null) { // Create Record Controller controller = new Controller(database); controller.AddCity(cityName, state, ID); this.parent.LoadCityMachinesDataGrid(); this.Close(); } else { MessageBox.Show("Please enter a City, State, and a uniquie ID."); } } else { MessageBox.Show("ID already exists. Please enter a uniqueID."); } } catch { MessageBox.Show("Invalid Entries - Please enter a City, State, and a uniquie ID."); } }