diff --git a/Data/Drinks/CandlehearthCoffee.cs b/Data/Drinks/CandlehearthCoffee.cs index 2db6b513..410e471c 100644 --- a/Data/Drinks/CandlehearthCoffee.cs +++ b/Data/Drinks/CandlehearthCoffee.cs @@ -154,7 +154,7 @@ public bool Decaf } else { - SpecialInstructions.Remove("Decaf"); + specialInstructions.Remove("Decaf"); } OnPropertyChanged("SpecialInstructions"); } diff --git a/Data/Drinks/SailorSoda.cs b/Data/Drinks/SailorSoda.cs index f54d221a..afed307b 100644 --- a/Data/Drinks/SailorSoda.cs +++ b/Data/Drinks/SailorSoda.cs @@ -118,6 +118,8 @@ public SodaFlavor Flavor { flavor = value; OnPropertyChanged("Flavor"); + OnPropertyChanged("SpecialInstructions"); + OnPropertyChanged("Name"); } } diff --git a/Data/Order.cs b/Data/Order.cs index de331173..ac3a68b2 100644 --- a/Data/Order.cs +++ b/Data/Order.cs @@ -25,18 +25,10 @@ public class Order : ObservableCollection /// /// Constructor for an Order /// - /// Boolean representing whether this order is new or not. Will be true if user clicked "Finish Order", false if they canceled - public Order(bool newOrder) + public Order() { Number = nextOrderNumber; - if (newOrder) - { - nextOrderNumber++; - Number = nextOrderNumber; - - } - - + nextOrderNumber++; CollectionChanged += CollectionChangedListener; } @@ -113,10 +105,10 @@ public uint Calories void CollectionChangedListener(object sender, NotifyCollectionChangedEventArgs e) { - OnPropertyChanged(new PropertyChangedEventArgs("Tax")); - OnPropertyChanged(new PropertyChangedEventArgs("Total")); - OnPropertyChanged(new PropertyChangedEventArgs("Calories")); - OnPropertyChanged(new PropertyChangedEventArgs("Subtotal")); + //OnPropertyChanged(new PropertyChangedEventArgs("Tax")); + //OnPropertyChanged(new PropertyChangedEventArgs("Total")); + //OnPropertyChanged(new PropertyChangedEventArgs("Calories")); + //OnPropertyChanged(new PropertyChangedEventArgs("Subtotal")); switch (e.Action) { @@ -124,20 +116,20 @@ void CollectionChangedListener(object sender, NotifyCollectionChangedEventArgs e foreach (IOrderItem item in e.NewItems) { item.PropertyChanged += CollectionItemChangedListener; - //OnPropertyChanged(new PropertyChangedEventArgs("Subtotal")); - //OnPropertyChanged(new PropertyChangedEventArgs("Tax")); - //OnPropertyChanged(new PropertyChangedEventArgs("Total")); - //OnPropertyChanged(new PropertyChangedEventArgs("Calories")); + OnPropertyChanged(new PropertyChangedEventArgs("Subtotal")); + OnPropertyChanged(new PropertyChangedEventArgs("Tax")); + OnPropertyChanged(new PropertyChangedEventArgs("Total")); + OnPropertyChanged(new PropertyChangedEventArgs("Calories")); } break; case NotifyCollectionChangedAction.Remove: // If the item is removed from the list, remove the event listener foreach (IOrderItem item in e.OldItems) { item.PropertyChanged -= CollectionItemChangedListener; - //OnPropertyChanged(new PropertyChangedEventArgs("Subtotal")); - //OnPropertyChanged(new PropertyChangedEventArgs("Tax")); - //OnPropertyChanged(new PropertyChangedEventArgs("Total")); - //OnPropertyChanged(new PropertyChangedEventArgs("Calories")); + OnPropertyChanged(new PropertyChangedEventArgs("Subtotal")); + OnPropertyChanged(new PropertyChangedEventArgs("Tax")); + OnPropertyChanged(new PropertyChangedEventArgs("Total")); + OnPropertyChanged(new PropertyChangedEventArgs("Calories")); } break; case NotifyCollectionChangedAction.Reset: // Big change, start over from scratch diff --git a/DataTests/DataTests.csproj b/DataTests/DataTests.csproj index 554961f6..420d5eb1 100644 --- a/DataTests/DataTests.csproj +++ b/DataTests/DataTests.csproj @@ -19,6 +19,7 @@ + diff --git a/DataTests/UnitTests/OrderTests.cs b/DataTests/UnitTests/OrderTests.cs index 0a1e3b55..7107b8de 100644 --- a/DataTests/UnitTests/OrderTests.cs +++ b/DataTests/UnitTests/OrderTests.cs @@ -24,7 +24,7 @@ public class OrderTests [Fact] public void ShouldImplementINotifyPropertyChanged() { - Assert.IsAssignableFrom >(new Order(false)); + Assert.IsAssignableFrom >(new Order()); } /// @@ -33,7 +33,7 @@ public void ShouldImplementINotifyPropertyChanged() [Fact] public void SalesTaxRateShouldBeTwelvePercentByDefault() { - Order o = new Order(false); + Order o = new Order(); Assert.Equal(0.12, o.SalesTaxRate); } @@ -43,7 +43,7 @@ public void SalesTaxRateShouldBeTwelvePercentByDefault() [Fact] public void ShouldBeAbleToSetSalesTaxRate() { - Order o = new Order(false); + Order o = new Order(); o.SalesTaxRate = 0.2; Assert.Equal(0.2, o.SalesTaxRate); } @@ -54,7 +54,7 @@ public void ShouldBeAbleToSetSalesTaxRate() [Fact] public void SubtotalShouldBeZeroByDefault() { - Order o = new Order(false); + Order o = new Order(); Assert.Equal(0, o.Subtotal); } @@ -64,7 +64,7 @@ public void SubtotalShouldBeZeroByDefault() [Fact] public void TotalShouldBeZeroByDefault() { - Order o = new Order(false); + Order o = new Order(); Assert.Equal(0, o.Total); } @@ -74,14 +74,14 @@ public void TotalShouldBeZeroByDefault() [Fact] public void TaxShouldBeZeroByDefault() { - Order o = new Order(false); + Order o = new Order(); Assert.Equal(0, o.Tax); } [Fact] public void SubtotalShouldBeSumOfOrderItemPrices() { - Order o = new Order(false); + Order o = new Order(); BriarheartBurger b = new BriarheartBurger(); SailorSoda s = new SailorSoda(); FriedMiraak f = new FriedMiraak(); @@ -94,7 +94,7 @@ public void SubtotalShouldBeSumOfOrderItemPrices() [Fact] public void TaxShouldBeSubtotalTimesTaxRate() { - Order o = new Order(false); + Order o = new Order(); BriarheartBurger b = new BriarheartBurger(); SailorSoda s = new SailorSoda(); FriedMiraak f = new FriedMiraak(); @@ -108,7 +108,7 @@ public void TaxShouldBeSubtotalTimesTaxRate() [Fact] public void TotalShouldBeSubtotalPlusTax() { - Order o = new Order(false); + Order o = new Order(); BriarheartBurger b = new BriarheartBurger(); SailorSoda s = new SailorSoda(); FriedMiraak f = new FriedMiraak(); @@ -127,7 +127,7 @@ public void TotalShouldBeSubtotalPlusTax() [Fact] public void CaloriesShouldBeSumOfAllCaloriesInTheOrder() { - Order o = new Order(false); + Order o = new Order(); BriarheartBurger b = new BriarheartBurger(); SailorSoda s = new SailorSoda(); FriedMiraak f = new FriedMiraak(); @@ -138,21 +138,126 @@ public void CaloriesShouldBeSumOfAllCaloriesInTheOrder() } /// - /// Makes sure order number is 1 by default + /// Makes sure each consecutive order number increases by one /// [Fact] - public void OrderNumberShouldBeOneByDefault() + public void OrderNumberShouldIncrementWithANewOrder() { - Order o = new Order(false); - Assert.Equal(1, o.Number); + Order o = new Order(); + Order o2 = new Order(); + Assert.Equal(1, o2.Number - o.Number); } + /// + /// Makes sure adding an item notifies the order subtotal property + /// [Fact] - public void OrderNumberShouldIncrementWithANewOrder() + public void AddingItemShouldNotifySubtotalProperty() + { + Order o = new Order(); + Assert.PropertyChanged(o, "Subtotal", () => + { + o.Add(new DoubleDraugr()); + }); + } + + /// + /// Makes sure adding an item notifies the order tax property + /// + [Fact] + public void AddingItemShouldNotifyTaxProperty() + { + Order o = new Order(); + Assert.PropertyChanged(o, "Tax", () => + { + o.Add(new DoubleDraugr()); + }); + } + + /// + /// Makes sure adding an item notifies the order total property + /// + [Fact] + public void AddingItemShouldNotifyTotalProperty() + { + Order o = new Order(); + Assert.PropertyChanged(o, "Total", () => + { + o.Add(new DoubleDraugr()); + }); + } + + /// + /// Makes sure adding an item notifies the order calories property + /// + [Fact] + public void AddingItemShouldNotifyCaloriesProperty() + { + Order o = new Order(); + Assert.PropertyChanged(o, "Calories", () => + { + o.Add(new DoubleDraugr()); + }); + } + + /// + /// Makes sure changing an item notifies the order subtotal property + /// + [Fact] + public void ChangingItemShouldNotifySubtotalProperty() + { + Order o = new Order(); + SailorSoda s = new SailorSoda(); + o.Add(s); + Assert.PropertyChanged(o, "Subtotal", () => + { + s.Size = Data.Enums.Size.Large; + }); + } + + /// + /// Makes sure changing an item notifies the order tax property + /// + [Fact] + public void ChangingItemShouldNotifyTaxProperty() { - Order o = new Order(false); - Order o2 = new Order(true); - Assert.Equal(2, o2.Number); + Order o = new Order(); + SailorSoda s = new SailorSoda(); + o.Add(s); + Assert.PropertyChanged(o, "Tax", () => + { + s.Size = Data.Enums.Size.Large; + }); + } + + /// + /// Makes sure changing an item notifies the order total property + /// + [Fact] + public void ChangingItemShouldNotifyTotalProperty() + { + Order o = new Order(); + SailorSoda s = new SailorSoda(); + o.Add(s); + Assert.PropertyChanged(o, "Total", () => + { + s.Size = Data.Enums.Size.Large; + }); + } + + /// + /// Makes sure changing an item notifies the order calories property + /// + [Fact] + public void ChangingItemShouldNotifyCaloriesProperty() + { + Order o = new Order(); + SailorSoda s = new SailorSoda(); + o.Add(s); + Assert.PropertyChanged(o, "Calories", () => + { + s.Size = Data.Enums.Size.Large; + }); } } } diff --git a/DataTests/UnitTests/UpdateCashDrawerTests.cs b/DataTests/UnitTests/UpdateCashDrawerTests.cs new file mode 100644 index 00000000..aa3ef350 --- /dev/null +++ b/DataTests/UnitTests/UpdateCashDrawerTests.cs @@ -0,0 +1,1124 @@ +using BleakwindBuffet.Data; +using PointOfSale; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; +using System.Threading; +using Xunit; +//using RoundRegister; + +namespace BleakwindBuffet.DataTests.UnitTests +{ + public class UpdateCashDrawerTests + { + /// + /// Checks to make sure UpdateCashDrawer implements INotifyPropertyChanged interface + /// + [Fact] + public void ShouldImplementINotifyPropertyChanged() + { + //RoundRegister.CashDrawer.Reset(); + Order o = new Order(); + Assert.IsAssignableFrom(new UpdateCashDrawer(o.Total)); + } + + [Fact] + public void TotalCostGetterShouldGetCorrectNumber() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.Equal(o.Total, u.TotalCost); + } + + [Fact] + public void TotalPaidGetterShouldGetCorrectNumber() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + u.PaidTens = 1; + Assert.Equal(10, u.TotalPaid); + } + + [Theory] + [InlineData(3, 5)] + [InlineData(0, 1.5)] + [InlineData(2, 1.7)] + [InlineData(15, 17.89)] + public void AmountDueGetterShouldGetCorrectNumber(int paidOnes, double totalCost) + { + UpdateCashDrawer u = new UpdateCashDrawer(totalCost); + u.PaidOnes = paidOnes; + double amountDue = Math.Round(totalCost - paidOnes, 2); + if (amountDue < 0) + { + Assert.Equal(0, u.AmountDue); + } + else + { + Assert.Equal(amountDue, u.AmountDue); + } + } + + [Theory] + [InlineData(15, 14.20)] + [InlineData(2, 0.79)] + [InlineData(1, 24)] + public void ChangeOwedGetterShouldGetCorrectNumber(int paidOnes, double totalCost) + { + + UpdateCashDrawer u = new UpdateCashDrawer(totalCost); + u.PaidOnes = paidOnes; + double changeOwed = Math.Round(paidOnes - totalCost, 2); + if (changeOwed < 0) + { + Assert.Equal(0, u.ChangeOwed); + } + else + { + u.ChangeOwed = changeOwed; + Assert.Equal(changeOwed, u.ChangeOwed); + } + } + + /// + /// Makes sure changing the paid pennies property notifies paid pennies property + /// + [Fact] + public void ChangingPaidPenniesShouldNotifyPaidPenniesProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidPennies", () => + { + u.PaidPennies++; + }); + } + + /// + /// Makes sure changing the paid pennies property notifies total paid property + /// + [Fact] + public void ChangingPaidPenniesShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidPennies++; + }); + } + + /// + /// Makes sure changing the paid pennies property notifies amount due property + /// + [Fact] + public void ChangingPaidPenniesShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidPennies++; + }); + } + + /// + /// Makes sure changing the paid nickels property notifies paid nickels property + /// + [Fact] + public void ChangingPaidNickelsShouldNotifyPaidNickelsProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidNickels", () => + { + u.PaidNickels++; + }); + } + + /// + /// Makes sure changing the paid nickels property notifies total paid property + /// + [Fact] + public void ChangingPaidNickelsShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidNickels++; + }); + } + + /// + /// Makes sure changing the paid nickels property notifies amount due property + /// + [Fact] + public void ChangingPaidNickelsShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidNickels++; + }); + } + + /// + /// Makes sure changing the paid dimes property notifies paid dimes property + /// + [Fact] + public void ChangingPaidDimesShouldNotifyPaidDimesProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidDimes", () => + { + u.PaidDimes++; + }); + } + + /// + /// Makes sure changing the paid dimes property notifies total paid property + /// + [Fact] + public void ChangingPaidDimesShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidDimes++; + }); + } + + /// + /// Makes sure changing the paid dimes property notifies amount due property + /// + [Fact] + public void ChangingPaidDimesShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidDimes++; + }); + } + + /// + /// Makes sure changing the paid quarters property notifies paid quarters property + /// + [Fact] + public void ChangingPaidQuartersShouldNotifyPaidQuartersProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidQuarters", () => + { + u.PaidQuarters++; + }); + } + + /// + /// Makes sure changing the paid quarters property notifies total paid property + /// + [Fact] + public void ChangingPaidQuartersShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidQuarters++; + }); + } + + /// + /// Makes sure changing the paid quarters property notifies amount due property + /// + [Fact] + public void ChangingPaidQuartersShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidQuarters++; + }); + } + + /// + /// Makes sure changing the paid half dollars property notifies paid half dollars property + /// + [Fact] + public void ChangingPaidHalfDollarsShouldNotifyPaidHalfDollarsProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidHalfDollars", () => + { + u.PaidHalfDollars++; + }); + } + + /// + /// Makes sure changing the paid half dollars property notifies total paid property + /// + [Fact] + public void ChangingPaidHalfDollarsShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidHalfDollars++; + }); + } + + /// + /// Makes sure changing the paid half dollars property notifies amount due property + /// + [Fact] + public void ChangingPaidHalfDollarsShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidHalfDollars++; + }); + } + + /// + /// Makes sure changing the paid dollars property notifies paid quarters property + /// + [Fact] + public void ChangingPaidDollarsShouldNotifyPaidDollarsProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidDollars", () => + { + u.PaidDollars++; + }); + } + + /// + /// Makes sure changing the paid dollars property notifies total paid property + /// + [Fact] + public void ChangingPaidDollarsShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidDollars++; + }); + } + + /// + /// Makes sure changing the paid dollars property notifies amount due property + /// + [Fact] + public void ChangingPaidDollarsShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidDollars++; + }); + } + + /// + /// Makes sure changing the paid ones property notifies paid ones property + /// + [Fact] + public void ChangingPaidOnesShouldNotifyPaidOnesProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidOnes", () => + { + u.PaidOnes++; + }); + } + + /// + /// Makes sure changing the paid ones property notifies total paid property + /// + [Fact] + public void ChangingPaidOnesShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidOnes++; + }); + } + + /// + /// Makes sure changing the paid ones property notifies amount due property + /// + [Fact] + public void ChangingPaidOnesShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidOnes++; + }); + } + + /// + /// Makes sure changing the paid quarters property notifies paid quarters property + /// + [Fact] + public void ChangingPaidTwosShouldNotifyPaidTwosProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidTwos", () => + { + u.PaidTwos++; + }); + } + + /// + /// Makes sure changing the paid twos property notifies total paid property + /// + [Fact] + public void ChangingPaidTwosShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidTwos++; + }); + } + + /// + /// Makes sure changing the paid twos property notifies amount due property + /// + [Fact] + public void ChangingPaidTwosShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidTwos++; + }); + } + + /// + /// Makes sure changing the paid fives property notifies paid fives property + /// + [Fact] + public void ChangingPaidFivesShouldNotifyPaidQuartersProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidFives", () => + { + u.PaidFives++; + }); + } + + /// + /// Makes sure changing the paid fives property notifies total paid property + /// + [Fact] + public void ChangingPaidFivesShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidFives++; + }); + } + + /// + /// Makes sure changing the paid fives property notifies amount due property + /// + [Fact] + public void ChangingPaidFivesShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidFives++; + }); + } + + /// + /// Makes sure changing the paid tens property notifies paid tens property + /// + [Fact] + public void ChangingPaidTensShouldNotifyPaidTensProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidTens", () => + { + u.PaidTens++; + }); + } + + /// + /// Makes sure changing the paid tens property notifies total paid property + /// + [Fact] + public void ChangingPaidTensShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidTens++; + }); + } + + /// + /// Makes sure changing the paid tens property notifies amount due property + /// + [Fact] + public void ChangingPaidTensShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidTens++; + }); + } + + /// + /// Makes sure changing the paid twenties property notifies paid twenties property + /// + [Fact] + public void ChangingPaidTwentiesShouldNotifyPaidTwentiesProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidTwenties", () => + { + u.PaidTwenties++; + }); + } + + /// + /// Makes sure changing the paid twenties property notifies total paid property + /// + [Fact] + public void ChangingPaidTwentiesShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidTwenties++; + }); + } + + /// + /// Makes sure changing the paid twenties property notifies amount due property + /// + [Fact] + public void ChangingPaidTwentiesShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidTwenties++; + }); + } + + /// + /// Makes sure changing the paid fifties property notifies paid fifties property + /// + [Fact] + public void ChangingPaidFiftiesShouldNotifyPaidFiftiesProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidFifties", () => + { + u.PaidFifties++; + }); + } + + /// + /// Makes sure changing the paid fifties property notifies total paid property + /// + [Fact] + public void ChangingPaidFiftiesShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidFifties++; + }); + } + + /// + /// Makes sure changing the paid fifties property notifies amount due property + /// + [Fact] + public void ChangingPaidFitfiesShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidFifties++; + }); + } + + /// + /// Makes sure changing the paid hundreds property notifies paid hundreds property + /// + [Fact] + public void ChangingPaidHundredsShouldNotifyPaidHundredsProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "PaidHundreds", () => + { + u.PaidHundreds++; + }); + } + + /// + /// Makes sure changing the paid hundreds property notifies total paid property + /// + [Fact] + public void ChangingPaidHundredsShouldNotifyTotalPaidProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "TotalPaid", () => + { + u.PaidHundreds++; + }); + } + + /// + /// Makes sure changing the paid hundreds property notifies amount due property + /// + [Fact] + public void ChangingPaidHundredsShouldNotifyAmountDueProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "AmountDue", () => + { + u.PaidHundreds++; + }); + } + + /// + /// Makes sure changing the paid fifties property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidFiftiesShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidFifties++; + }); + } + + /// + /// Makes sure changing the paid twenties property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidTwentiesShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidTwenties++; + }); + } + + /// + /// Makes sure changing the paid tens property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidTensShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidTens++; + }); + } + + /// + /// Makes sure changing the paid fives property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidFivesShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidFives++; + }); + } + + /// + /// Makes sure changing the paid twos property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidTwosShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidTwos++; + }); + } + + /// + /// Makes sure changing the paid ones property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidOnesShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidOnes++; + }); + } + + /// + /// Makes sure changing the paid dollars property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidDollarsShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidDollars++; + }); + } + + /// + /// Makes sure changing the paid half dollars property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidHalfDollarsShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidHalfDollars++; + }); + } + + /// + /// Makes sure changing the paid quarters property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidQuartersShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidQuarters++; + }); + } + + /// + /// Makes sure changing the paid dimes property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidDimesShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidDimes++; + }); + } + + /// + /// Makes sure changing the paid nickels property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidNickelsShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidNickels++; + }); + } + + /// + /// Makes sure changing the paid pennies property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidPenniesShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidPennies++; + }); + } + + /// + /// Makes sure changing the paid hundreds property notifies FinalizeSaleButtonEnabled property + /// + [Fact] + public void ChangingPaidHundredsShouldNotifyFinalizeSaleButtonEnabledProperty() + { + Order o = new Order(); + UpdateCashDrawer u = new UpdateCashDrawer(o.Total); + Assert.PropertyChanged(u, "FinalizeSaleButtonEnabled", () => + { + u.PaidHundreds++; + }); + } + + /// + /// Makes sure ChangePennies is settable + /// + [Fact] + public void ChangePenniesShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangePennies = 1; + Assert.Equal(1, u.ChangePennies); + } + + /// + /// Makes sure ChangeNickels is settable + /// + [Fact] + public void ChangeNickelsShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeNickels = 1; + Assert.Equal(1, u.ChangeNickels); + } + + /// + /// Makes sure ChangeDimes is settable + /// + [Fact] + public void ChangeDimesShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeDimes = 1; + Assert.Equal(1, u.ChangeDimes); + } + + /// + /// Makes sure ChangeQuarters is settable + /// + [Fact] + public void ChangeQuartersShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeQuarters = 1; + Assert.Equal(1, u.ChangeQuarters); + } + + /// + /// Makes sure ChangeHalfDollars is settable + /// + [Fact] + public void ChangeHalfDollarsShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeHalfDollars = 1; + Assert.Equal(1, u.ChangeHalfDollars); + } + + /// + /// Makes sure ChangeDollars is settable + /// + [Fact] + public void ChangeDollarsShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeDollars = 1; + Assert.Equal(1, u.ChangeDollars); + } + + /// + /// Makes sure ChangeOnes is settable + /// + [Fact] + public void ChangeOnesShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeOnes = 1; + Assert.Equal(1, u.ChangeOnes); + } + + /// + /// Makes sure ChangeTwos is settable + /// + [Fact] + public void ChangeTwosShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeTwos = 1; + Assert.Equal(1, u.ChangeTwos); + } + + /// + /// Makes sure ChangeFives is settable + /// + [Fact] + public void ChangeFivesShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeFives = 1; + Assert.Equal(1, u.ChangeFives); + } + + /// + /// Makes sure ChangeTens is settable + /// + [Fact] + public void ChangeTensShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeTens = 1; + Assert.Equal(1, u.ChangeTens); + } + + /// + /// Makes sure ChangeTwenties is settable + /// + [Fact] + public void ChangeTwentiesShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeTwenties = 1; + Assert.Equal(1, u.ChangeTwenties); + } + + /// + /// Makes sure ChangeFifties is settable + /// + [Fact] + public void ChangeFiftiesShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeFifties = 1; + Assert.Equal(1, u.ChangeFifties); + } + + /// + /// Makes sure ChangeHundreds is settable + /// + [Fact] + public void ChangeHundredsShouldBeSettable() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + u.ChangeHundreds = 1; + Assert.Equal(1, u.ChangeHundreds); + } + + /// + /// Makes sure changing ChangeHundreds notifies property changed + /// + [Fact] + public void ChangingChangeHundredsShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeHundreds", () => + { + u.ChangeHundreds++; + }); + } + + /// + /// Makes sure changing ChangeFifties notifies property changed + /// + [Fact] + public void ChangingChangeFiftiesShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeFifties", () => + { + u.ChangeFifties++; + }); + } + + /// + /// Makes sure changing ChangeTwenties notifies property changed + /// + [Fact] + public void ChangingChangeTwentiesShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeTwenties", () => + { + u.ChangeTwenties++; + }); + } + + /// + /// Makes sure changing ChangeTens notifies property changed + /// + [Fact] + public void ChangingChangeTensShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeTens", () => + { + u.ChangeTens++; + }); + } + + /// + /// Makes sure changing ChangeFives notifies property changed + /// + [Fact] + public void ChangingChangeFivesShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeFives", () => + { + u.ChangeFives++; + }); + } + + /// + /// Makes sure changing ChangeTwos notifies property changed + /// + [Fact] + public void ChangingChangeTwosShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeTwos", () => + { + u.ChangeTwos++; + }); + } + + /// + /// Makes sure changing ChangeOnes notifies property changed + /// + [Fact] + public void ChangingChangeOnesShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeOnes", () => + { + u.ChangeOnes++; + }); + } + + /// + /// Makes sure changing ChangeDollars notifies property changed + /// + [Fact] + public void ChangingChangeDollarsShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeDollars", () => + { + u.ChangeDollars++; + }); + } + + /// + /// Makes sure changing ChangeHalfDollars notifies property changed + /// + [Fact] + public void ChangingChangeHalfDollarsShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeHalfDollars", () => + { + u.ChangeHalfDollars++; + }); + } + + /// + /// Makes sure changing ChangeQuarters notifies property changed + /// + [Fact] + public void ChangingChangeQuartersShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeQuarters", () => + { + u.ChangeQuarters++; + }); + } + + /// + /// Makes sure changing ChangeDimes notifies property changed + /// + [Fact] + public void ChangingChangeDimesShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeDimes", () => + { + u.ChangeDimes++; + }); + } + + /// + /// Makes sure changing ChangeNickels notifies property changed + /// + [Fact] + public void ChangingChangeNickelsShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangeNickels", () => + { + u.ChangeNickels++; + }); + } + + /// + /// Makes sure changing ChangePennies notifies property changed + /// + [Fact] + public void ChangingChangePenniesShouldNotifyPropertyChanged() + { + UpdateCashDrawer u = new UpdateCashDrawer(0); + Assert.PropertyChanged(u, "ChangePennies", () => + { + u.ChangePennies++; + }); + } + } +} diff --git a/Documentation/BleakwindBuffetClassUML.vsdx b/Documentation/BleakwindBuffetClassUML.vsdx index e59b54c0..66411673 100644 Binary files a/Documentation/BleakwindBuffetClassUML.vsdx and b/Documentation/BleakwindBuffetClassUML.vsdx differ diff --git a/Documentation/RoundRegisterUML.pdf b/Documentation/RoundRegisterUML.pdf new file mode 100644 index 00000000..5403421c Binary files /dev/null and b/Documentation/RoundRegisterUML.pdf differ diff --git a/PointOfSale/CashPayment.xaml b/PointOfSale/CashPayment.xaml new file mode 100644 index 00000000..0c75bbee --- /dev/null +++ b/PointOfSale/CashPayment.xaml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From Customer + Give as Change + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From Customer + Give as Change + + + + + + + + + + + + + + Total Sale: + + + + Amount Due: + + + + Change Owed: + + + + + + + + + diff --git a/PointOfSale/CashPayment.xaml.cs b/PointOfSale/CashPayment.xaml.cs new file mode 100644 index 00000000..162ec83b --- /dev/null +++ b/PointOfSale/CashPayment.xaml.cs @@ -0,0 +1,71 @@ +using BleakwindBuffet.Data; +using RoundRegister; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace PointOfSale +{ + /// + /// Interaction logic for CashPayment.xaml + /// + public partial class CashPayment : UserControl + { + double totalCost = 0; + Order thisOrder = new Order(); + UpdateCashDrawer cashDrawer; + public CashPayment(Order order) + { + InitializeComponent(); + TotalCost = order.Total; + thisOrder = order; + cashDrawer = new UpdateCashDrawer(TotalCost); + DataContext = cashDrawer; + } + + public double TotalCost + { + get { return totalCost; } + set { totalCost = value; } + } + + /// + /// Event handler for if user wants to return to their order + /// + /// + /// + public void ReturnToOrderClicked(object sender, RoutedEventArgs e) + { + MainMenuSelection main = new MainMenuSelection(); + OrderComponent orderComponent = this.FindAncestor(); // Find the Order Component that is a parent of the current order summary + orderComponent.Swap(main); + } + + /// + /// Event handler for if the user wants to finalize the sale + /// + /// + /// + public void FinalizeSaleClicked(object sender, RoutedEventArgs e) + { + cashDrawer.PrintReceipt(true, thisOrder); + Order newOrder = new Order(); + MainMenuSelection main = new MainMenuSelection(); + OrderComponent orderComponent = this.FindAncestor(); // Find the Order Component that is a parent of the current order summary + orderComponent.DataContext = newOrder; // Set the data context of the order component to be the new order + orderComponent.Swap(main); + } + + + } +} diff --git a/PointOfSale/CurrencyControl.xaml b/PointOfSale/CurrencyControl.xaml new file mode 100644 index 00000000..8bd71b3f --- /dev/null +++ b/PointOfSale/CurrencyControl.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/PointOfSale/CurrencyControl.xaml.cs b/PointOfSale/CurrencyControl.xaml.cs new file mode 100644 index 00000000..8d01be34 --- /dev/null +++ b/PointOfSale/CurrencyControl.xaml.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace PointOfSale +{ + /// + /// Interaction logic for CurrencyControl.xaml + /// + public partial class CurrencyControl : UserControl + { + public CurrencyControl() + { + InitializeComponent(); + } + + static FrameworkPropertyMetadata labelMetadata = new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault); + public static DependencyProperty LabelProperty = DependencyProperty.Register("Label", typeof(string), typeof(CurrencyControl)); + + static FrameworkPropertyMetadata customerMetadata = new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault); + + public static DependencyProperty CustomerQuantityProperty = DependencyProperty.Register("CustomerQuantity", typeof(int), typeof(CurrencyControl), customerMetadata); + + static FrameworkPropertyMetadata changeMetadata = new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault); + + public static DependencyProperty ChangeQuantityProperty = DependencyProperty.Register("ChangeQuantity", typeof(int), typeof(CurrencyControl), changeMetadata); + + /// + /// Represents the value held in currency control's label + /// + public string Label + { + get { return (string)GetValue(LabelProperty); } + set { SetValue(LabelProperty, value); } + } + + /// + /// Represents the quantity of currency of a certain type the customer pays with + /// + public int CustomerQuantity + { + get { return (int)GetValue(CustomerQuantityProperty); } + set { SetValue(CustomerQuantityProperty, value); } + } + + /// + /// Represents the quantity of currency of a certain type that the customer is owed in change + /// + public int ChangeQuantity + { + get { return (int)GetValue(ChangeQuantityProperty); } + set { SetValue(ChangeQuantityProperty, value); } + } + + /// + /// Event handler for if the increment button is clicked + /// + /// + /// + private void IncrementButtonClick(object sender, RoutedEventArgs e) + { + CustomerQuantity++; + e.Handled = true; + } + + /// + /// Event handler for if the decrement button is clicked + /// + /// + /// + private void DecrementButtonClick(object sender, RoutedEventArgs e) + { + if (CustomerQuantity > 0) + { + CustomerQuantity--; + } + + e.Handled = true; + } + + public void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (sender is CurrencyControl cc) + { + if (e.PropertyName == "CustomerQuantity") + { + + } + else if (e.PropertyName == "ChangeQuantity") + { + + } + } + } + } +} diff --git a/PointOfSale/CustomizeDrinks/CustomizeSailorSoda.xaml b/PointOfSale/CustomizeDrinks/CustomizeSailorSoda.xaml index e8a79d85..019b5e09 100644 --- a/PointOfSale/CustomizeDrinks/CustomizeSailorSoda.xaml +++ b/PointOfSale/CustomizeDrinks/CustomizeSailorSoda.xaml @@ -44,7 +44,7 @@