public void Test_AddAlloyWheel() { int savedId = Product.GetNextAvailableId(); Assert.IsTrue(AlloyWheel.AddNewAlloyWheel(new AlloyWheel (savedId, "215/55X20 MAX ALLOYWHEEL", 1, 1000, "MAX", "215/55X20"))); }
public void Test_DupplicateAlloyWheel() { int savedId = Product.GetNextAvailableId(); Assert.IsTrue(AlloyWheel.AddNewAlloyWheel(new AlloyWheel (savedId, "215/55X22 MAX ALLOYWHEEL", 1, 1000, "MAX", "215/55X22"))); Assert.IsFalse(AlloyWheel.AddNewAlloyWheel(new AlloyWheel (Product.GetNextAvailableId(), "215/55X22 MAX ALLOYWHEEL", 1, 1000, "MAX", "215/55X22"))); }
public void Test_GetAlloyWheel() { int savedId = Product.GetNextAvailableId(); AlloyWheel testAlloyWheel = new AlloyWheel (savedId, "215/55X21 MAX ALLOYWHEEL", 1, 1000, "MAX", "215/55X20"); AlloyWheel.AddNewAlloyWheel(testAlloyWheel); Assert.AreEqual (testAlloyWheel.Name, AlloyWheel.GetAlloyWheels(id: savedId.ToString()).ElementAt(0).Name); Assert.AreEqual (testAlloyWheel.Name, AlloyWheel.GetAlloyWheels(name: testAlloyWheel.Name).ElementAt(0).Name); }
private bool AddNewItemInfo() { switch (_selectedItemType) { case "Tyre": return(Tyre.AddNewTyre((Tyre)_selectedItem)); case "Alloy Wheel": return(AlloyWheel.AddNewAlloyWheel((AlloyWheel)_selectedItem)); case "Battery": return(Battery.AddNewBattery((Battery)_selectedItem)); } return(false); }
private void PropertyTextBox_TextChanged(object sender, TextChangedEventArgs e) { switch (_selectedItemType) { case "Tyre": NameTextBox.Text = Tyre.GenerateName(DimensionTextBox.Text, BrandTextBox.Text, CountryTextBox.Text); break; case "Alloy Wheel": NameTextBox.Text = AlloyWheel.GenerateName(DimensionTextBox.Text, BrandTextBox.Text); break; case "Battery": NameTextBox.Text = Battery.GenerateName(BrandTextBox.Text, DimensionTextBox.Text); break; } }
private void LoadItemSource(string id = "%", string name = "%") { switch (_selectedItemType) { case "Tyre": _itemSource = Tyre.GetTyres(id, name); break; case "Alloy Wheel": _itemSource = AlloyWheel.GetAlloyWheels(id, name); break; case "Battery": _itemSource = Battery.GetBatteries(id, name); break; } }
private bool UpdateItem() { if (IsDataInCorrectForm()) { CreateNewItemFromData(); switch (_selectedItemType) { case "Tyre": return(Tyre.UpdateTyres((Tyre)_selectedItem)); case "Alloy Wheel": return(AlloyWheel.UpdateAlloyWheel((AlloyWheel)_selectedItem)); case "Battery": return(Battery.UpdateBattery((Battery)_selectedItem)); } } return(false); }
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { _product = ComboBox.SelectedItem.ToString(); //assign the name of the item type if (_product.Equals("Alloy Wheel")) { _itemSource = AlloyWheel.GetAlloyWheels(); } else if (_product.Equals("Battery")) { _itemSource = Battery.GetBatteries(); } else if (_product.Equals("Tyre")) { _itemSource = Tyre.GetTyres(); } RefreshSearchDataGrid(); }
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) { var textBox = sender as TextBox; if (textBox?.Text != DefaultSearchText) { if (_product.Equals("Tyre")) { _itemSource = Tyre.GetTyres(name: textBox?.Text); DataGridSearch.ItemsSource = _itemSource; } else if (_product.Equals("Alloy Wheel")) { _itemSource = AlloyWheel.GetAlloyWheels(name: textBox?.Text); DataGridSearch.ItemsSource = _itemSource; } else if (_product.Equals("Battery")) { _itemSource = Battery.GetBatteries(name: textBox?.Text); DataGridSearch.ItemsSource = _itemSource; } } }