/// <summary> /// Changes screen to update for drink as soda /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Soda_Click(object sender, RoutedEventArgs e) { if (DataContext is Order order) { if (CollectionViewSource.GetDefaultView(order.Items).CurrentItem is DinoDiner.Menu.CretaceousCombo Combo) { Sodasaurus f = new Sodasaurus(); f.Size = Combo.Size; Combo.Drink = f; CollectionViewSource.GetDefaultView(order.Items).Refresh(); } } }
public void SodasaurusPropertyChangesShouldWorkProperly() { Sodasaurus ss = new Sodasaurus(); Assert.PropertyChanged(ss, "Size", () => ss.Size = Size.Large); Assert.PropertyChanged(ss, "Price", () => ss.Size = Size.Large); Assert.PropertyChanged(ss, "Calories", () => ss.Size = Size.Large); Assert.PropertyChanged(ss, "Description", () => ss.Size = Size.Large); Assert.PropertyChanged(ss, "Description", () => ss.Flavor = SodasaurusFlavor.Cherry); Assert.PropertyChanged(ss, "Flavor", () => ss.Flavor = SodasaurusFlavor.Cherry); Assert.PropertyChanged(ss, "Ice", () => ss.Ice = true); Assert.PropertyChanged(ss, "Special", () => ss.Ice = true); }
public void SpecialShouldHoldIce() { Sodasaurus soda = new Sodasaurus(); soda.HoldIce(); Assert.Collection <string>(soda.Special, item => { Assert.Equal("Hold Ice", item); } ); }
public void TRexKingBurgerComboSpecialShouldChange() { TRexKingBurger t = new TRexKingBurger(); MeteorMacAndCheese m = new MeteorMacAndCheese(); CretaceousCombo combo = new CretaceousCombo(t); Sodasaurus s = new Sodasaurus(); combo.Side = m; combo.Drink = s; t.HoldMayo(); Assert.Equal("Hold Mayo", combo.Special[0]); Assert.Equal("Small Meteor Mac and Cheese", combo.Special[1]); Assert.Equal("Small Cola Sodasaurus", combo.Special[2]); }
public void OrderTotalCostShouldBeCorrect() { Order o = new Order(); PterodactylWings p = new PterodactylWings(); Fryceritops f = new Fryceritops(); Sodasaurus s = new Sodasaurus(); s.Size = Size.Large; o.addItems(p); o.addItems(s); o.addItems(f); Assert.Equal((p.Price + f.Price + s.Price) + (p.Price + f.Price + s.Price) * o.SalesTaxRate, o.TotalCost, 2); }
public void HoldingIceShouldAddToSpecial() { Sodasaurus soda = new Sodasaurus(); soda.HoldIce(); if (soda.Ice == true) { Assert.Collection <string>(soda.Special, item => { Assert.Equal("Hold Ice", item); }); } }
public void CorrectPriceCaloriesAfterSizeChanges() { Sodasaurus s = new Sodasaurus(); s.Size = Size.Large; Assert.Equal <double>(2.50, s.Price); Assert.Equal <uint>(208, s.Calories); s.Size = Size.Medium; Assert.Equal <double>(2.00, s.Price); Assert.Equal <uint>(156, s.Calories); s.Size = Size.Small; Assert.Equal <double>(1.50, s.Price); Assert.Equal <uint>(112, s.Calories); }
/// <summary> /// Navigates to the flavor select screen when you choose flavor on soda /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void FlavorScreen(object sender, RoutedEventArgs args) { if (!isCombo) { Sodasaurus s = (Sodasaurus)drink; NavigationService.Navigate(new FlavorSelection(s)); } else { if (combo.Drink is Sodasaurus soda) { NavigationService.Navigate(new FlavorSelection(soda)); } } }
/// <summary> /// Click handler for the soda button /// </summary> /// <param name="sender">The object that sent the event</param> /// <param name="e">The arguements of the event</param> private void SodaClick(object sender, RoutedEventArgs e) { show_soda(); DataContext = new Sodasaurus(); /*---------------------------------------------------------------- * Set the currently selected drink image * ----------------------------------------------------------------*/ BitmapImage drink = new BitmapImage(); drink.BeginInit(); drink.UriSource = new Uri("pack://application:,,,/" + img_srcs[0]); drink.EndInit(); SelectedDrink.Source = drink; }
public void ChangingSizeShouldNotifyPropertyChangePriceAndDescription(Size size) { Sodasaurus s = new Sodasaurus(); Assert.PropertyChanged(s, "Price", () => { s.Size = size; }); s = new Sodasaurus(); Assert.PropertyChanged(s, "Description", () => { s.Size = size; }); }
public void SodaSaurusToStringShouldGiveNameForSizeAndFlavor(Size size, SodasaurusFlavor flavor) { Sodasaurus soda = new Sodasaurus(); soda.Size = size; soda.Flavor = flavor; if (flavor != SodasaurusFlavor.RootBeer) { Assert.Equal($"{size} {flavor} Sodasaurus", soda.ToString()); } else { Assert.Equal($"{size} Root Beer Sodasaurus", soda.ToString()); } }
public void SizeChangeShouldCorrectlyChangePriceAndCalories() { Sodasaurus s = new Sodasaurus(); s.Size = Size.Medium; Assert.Equal(2, s.Price); Assert.Equal <uint>(156, s.Calories); s.Size = Size.Large; Assert.Equal(2.5, s.Price); Assert.Equal <uint>(208, s.Calories); s.Size = Size.Small; Assert.Equal(1.5, s.Price); Assert.Equal <uint>(112, s.Calories); }
private void ButtonOnClick(object sender, RoutedEventArgs e) { if (sender is Button button && DataContext is Order order) { Drink drink; if (button.Name == App.ConvertToID(new JurassicJava().ToString())) { drink = new JurassicJava(); SelectingJurassicJava(); } else if (button.Name == App.ConvertToID(new Sodasaurus().ToString())) { drink = new Sodasaurus(); SelectingSodasaurus(); } else if (button.Name == App.ConvertToID(new Tyrannotea().ToString())) { drink = new Tyrannotea(); SelectingTyrannotea(); } else { drink = new Water(); SelectingWater(); } if ((bool)(Sizes.Children[1] as RadioButton).IsChecked) { drink.Size = DinoDiner.Menu.Size.Medium; } else if ((bool)(Sizes.Children[2] as RadioButton).IsChecked) { drink.Size = DinoDiner.Menu.Size.Large; } if (wasCombo && CollectionViewSource.GetDefaultView(order.Items).CurrentItem is CretaceousCombo combo) { combo.Drink = drink; } else { order.Items.Add(drink); CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast(); } } }
public void CorrectSalesTaxCost() { Order order = new Order(); DinoNuggets dn = new DinoNuggets(); PrehistoricPBJ pbj = new PrehistoricPBJ(); JurassicJava java = new JurassicJava(); Sodasaurus soda = new Sodasaurus(); order.Add(dn); order.Add(pbj); order.Add(java); order.Add(soda); double sub = dn.Price + pbj.Price + java.Price + soda.Price; Assert.Equal(sub * .10, order.SalesTaxCost); }
public void ShouldHaveCorrectCaloriesAndPriceAfterSize() { Sodasaurus s = new Sodasaurus(); s.Size = Size.Medium; s.Size = Size.Small; Assert.Equal(1.5, s.Price); Assert.Equal <uint>(112, s.Calories); s.Size = Size.Medium; Assert.Equal(2, s.Price); Assert.Equal <uint>(156, s.Calories); s.Size = Size.Large; Assert.Equal(2.5, s.Price); Assert.Equal <uint>(208, s.Calories); }
public void CheckCorrectChangedPriceAndCalories() { Sodasaurus s = new Sodasaurus(); s.Size = Size.Large; Assert.Equal <Size>(s.Size, Size.Large); Assert.Equal <double>(s.Price, 2.50); Assert.Equal <uint>(s.Calories, 208); s.Size = Size.Medium; Assert.Equal <Size>(s.Size, Size.Medium); Assert.Equal <double>(s.Price, 2.00); Assert.Equal <uint>(s.Calories, 156); s.Size = Size.Small; Assert.Equal <Size>(s.Size, Size.Small); Assert.Equal <double>(s.Price, 1.50); Assert.Equal <uint>(s.Calories, 112); }
public void HoldIceWorksWithSpecial(bool holdIce) { Sodasaurus s = new Sodasaurus(); if (holdIce) { s.HoldIce(); } if (holdIce) { Assert.True(Array.Exists(s.Special, item => item.Equals("Hold Ice"))); } else { Assert.Empty(s.Special); } }
public void ChangingSizeShouldNotifyOfPropertyChanged(string propertyName) { Sodasaurus soda = new Sodasaurus(); Assert.PropertyChanged(soda, propertyName, () => { soda.Size = Size.Medium; }); Assert.PropertyChanged(soda, propertyName, () => { soda.Size = Size.Large; }); Assert.PropertyChanged(soda, propertyName, () => { soda.Size = Size.Small; }); }
public void SizeChangeShouldNotifyPropertyChange(string propertyName) { Sodasaurus s = new Sodasaurus(); Assert.PropertyChanged(s, propertyName, () => { s.Size = Size.Medium; }); Assert.PropertyChanged(s, propertyName, () => { s.Size = Size.Large; }); Assert.PropertyChanged(s, propertyName, () => { s.Size = Size.Small; }); }
public void ChangingSizeShouldNotifyEveryone() { Sodasaurus s = new Sodasaurus(); Assert.PropertyChanged(s, "Price", () => { s.Size = Size.Medium; }); Assert.PropertyChanged(s, "Description", () => { s.Size = Size.Medium; }); Assert.PropertyChanged(s, "Calories", () => { s.Size = Size.Medium; }); }
public void ChangeSizeShouldNotifyPriceAndCalories(Size size) { Sodasaurus soda = new Sodasaurus(); Assert.PropertyChanged(soda, "Price", () => { soda.Size = size; }); Assert.PropertyChanged(soda, "Calories", () => { soda.Size = size; }); Assert.PropertyChanged(soda, "Description", () => { soda.Size = size; }); }
public void ChangingSizeShouldNotifyDescriptionChange() { Sodasaurus soda = new Sodasaurus(); soda.Size = Size.Medium; Assert.PropertyChanged(soda, "Description", () => { soda.Size = Size.Medium; }); Assert.PropertyChanged(soda, "Calories", () => { soda.Size = Size.Medium; }); Assert.PropertyChanged(soda, "Price", () => { soda.Size = Size.Medium; }); }
public void BrontoComboSpecialShouldGiveCorrectArrayForSpecial() { Brontowurst b = new Brontowurst(); Drink d = new Sodasaurus(); CretaceousCombo c = new CretaceousCombo(b); c.Drink = d; b.HoldBun(); b.HoldOnion(); d.HoldIce(); Assert.Contains <string>("Hold Bun", c.Special); Assert.Contains <string>("Hold Onion", c.Special); Assert.Contains(c.Side.Description, c.Special[2]); Assert.Contains(d.Description, c.Special[3]); Assert.Contains("Hold Ice", c.Special[4]); }
/// <summary> /// Clicking on soda will add the "choose flavor" button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Click_Soda(object sender, RoutedEventArgs e) { SetSodaButtons(); if (DataContext is Order order) { if (isDrink) { Sodasaurus soda = new Sodasaurus(); _drink = soda; order.Add(_drink); } else if (isCombo) { _combo.Drink = new Sodasaurus(); } } }
public void ShouldBeAbleToChangeTheFlavor() { Sodasaurus soda = new Sodasaurus(); Assert.Equal(SodasaurusFlavor.Cola, soda.Flavor); soda.Flavor = SodasaurusFlavor.Orange; Assert.Equal(SodasaurusFlavor.Orange, soda.Flavor); soda.Flavor = SodasaurusFlavor.Vanilla; Assert.Equal(SodasaurusFlavor.Vanilla, soda.Flavor); soda.Flavor = SodasaurusFlavor.Chocolate; Assert.Equal(SodasaurusFlavor.Chocolate, soda.Flavor); soda.Flavor = SodasaurusFlavor.RootBeer; Assert.Equal(SodasaurusFlavor.RootBeer, soda.Flavor); soda.Flavor = SodasaurusFlavor.Cherry; Assert.Equal(SodasaurusFlavor.Cherry, soda.Flavor); soda.Flavor = SodasaurusFlavor.Lime; Assert.Equal(SodasaurusFlavor.Lime, soda.Flavor); }
public void SetEachFlavor() { Sodasaurus soda = new Sodasaurus(); soda.Flavor = SodasaurusFlavor.Cherry; Assert.Equal <SodasaurusFlavor>(SodasaurusFlavor.Cherry, soda.Flavor); soda.Flavor = SodasaurusFlavor.Chocolate; Assert.Equal <SodasaurusFlavor>(SodasaurusFlavor.Chocolate, soda.Flavor); soda.Flavor = SodasaurusFlavor.Cola; Assert.Equal <SodasaurusFlavor>(SodasaurusFlavor.Cola, soda.Flavor); soda.Flavor = SodasaurusFlavor.Grape; Assert.Equal <SodasaurusFlavor>(SodasaurusFlavor.Grape, soda.Flavor); soda.Flavor = SodasaurusFlavor.Orange; Assert.Equal <SodasaurusFlavor>(SodasaurusFlavor.Orange, soda.Flavor); soda.Flavor = SodasaurusFlavor.RootBeer; Assert.Equal <SodasaurusFlavor>(SodasaurusFlavor.RootBeer, soda.Flavor); soda.Flavor = SodasaurusFlavor.Vanilla; Assert.Equal <SodasaurusFlavor>(SodasaurusFlavor.Vanilla, soda.Flavor); }
public void OrderSalesTaxCostShouldBeCorrect() { Order o = new Order(); PrehistoricPBJ pb1 = new PrehistoricPBJ(); PrehistoricPBJ pb2 = new PrehistoricPBJ(); PrehistoricPBJ pb3 = new PrehistoricPBJ(); Triceritots tt = new Triceritots(); Sodasaurus ss = new Sodasaurus(); o.Add(pb1); o.Add(pb2); o.Add(pb3); o.Add(tt); o.Add(ss); double salesTax = (pb1.Price + pb2.Price + pb3.Price + tt.Price + ss.Price) * o.SalesTaxRate; Assert.Equal <double>(salesTax, o.SalesTaxCost); }
public void OrderSubTotalTest() { Order o = new Order(); Brontowurst bw = new Brontowurst(); MeteorMacAndCheese mc1 = new MeteorMacAndCheese(); Fryceritops ft = new Fryceritops(); ft.Size = Size.Medium; Sodasaurus s = new Sodasaurus(); s.Size = Size.Medium; o.Items.Add(bw); o.Items.Add(mc1); o.Items.Add(ft); o.Items.Add(s); double subtotal = bw.Price + ft.Price + mc1.Price + s.Price; Assert.Equal(subtotal, o.SubtotalCost); }
public void OrderSalesTaxTest() { Order o = new Order(); Brontowurst bw = new Brontowurst(); MeteorMacAndCheese mc1 = new MeteorMacAndCheese(); Fryceritops ft = new Fryceritops(); ft.Size = Size.Medium; Sodasaurus s = new Sodasaurus(); s.Size = Size.Medium; o.Items.Add(bw); o.Items.Add(mc1); o.Items.Add(ft); o.Items.Add(s); double taxed = (bw.Price + mc1.Price + ft.Price + s.Price) * o.SalesTaxRate; Assert.Equal(taxed, o.SalesTaxCost); }
public void ChangingFlavorShouldChangeDescription() { Sodasaurus soda = new Sodasaurus(); soda.Flavor = SodasaurusFlavor.Chocolate; Assert.Equal($"{soda.Size} Chocolate Sodasaurus", soda.Description); soda.Flavor = SodasaurusFlavor.Cola; Assert.Equal($"{soda.Size} Cola Sodasaurus", soda.Description); soda.Flavor = SodasaurusFlavor.Lime; Assert.Equal($"{soda.Size} Lime Sodasaurus", soda.Description); soda.Flavor = SodasaurusFlavor.Orange; Assert.Equal($"{soda.Size} Orange Sodasaurus", soda.Description); soda.Flavor = SodasaurusFlavor.RootBeer; Assert.Equal($"{soda.Size} RootBeer Sodasaurus", soda.Description); soda.Flavor = SodasaurusFlavor.Vanilla; Assert.Equal($"{soda.Size} Vanilla Sodasaurus", soda.Description); soda.Flavor = SodasaurusFlavor.Cherry; Assert.Equal($"{soda.Size} Cherry Sodasaurus", soda.Description); }