public void Test_OperatorInequality_NotOk() { ICoffee c1 = _factory.CreateCoffee("Espresso"); ICoffee c2 = _factory.CreateCoffee("Espresso"); Assert.IsFalse(c1 != c2); }
public void Test_GetHashCode_NotOk() { ICoffee c1 = _factory.CreateCoffee("Espresso"); ICoffee c2 = _factory.CreateCoffee("Cappuccino"); Assert.AreNotEqual(c1.GetHashCode(), c2.GetHashCode()); }
public void Test_OperatorInequality_Ok() { ICoffee c1 = _factory.CreateCoffee("Espresso"); ICoffee c2 = _factory.CreateCoffee("Cappuccino"); Assert.IsTrue(c1 != c2); }
public void AddToCart(ICoffee orderedCofee) { var isAvailable = cartRepository.IsCartItemAvailable(shoppingCartId, orderedCofee.Id); ICart cartItem; if (!isAvailable) { cartItem = cartFactory.CreateCart(); cartItem.CoffeeId = orderedCofee.Id; cartItem.CoffeeDescription = orderedCofee.FullDescription; cartItem.CoffeeCost = orderedCofee.Cost(); cartItem.ShoppingCartId = this.shoppingCartId; cartItem.Count = 1; cartRepository.Add(cartItem); } else { // Pls refactor cartItem = cartRepository.GetCartItemByCoffeeId(shoppingCartId, orderedCofee.Id); cartItem.Count++; cartRepository.Update(cartItem); } }
public void Test_Equals_Ok() { ICoffee c1 = _factory.CreateCoffee("Espresso"); ICoffee c2 = _factory.CreateCoffee("Espresso"); Assert.IsTrue(c1.Equals(c2)); }
bool CheckState(ICoffee chosenCoffee) { if (this.water < chosenCoffee.water) { Console.WriteLine("Sorry, not enough water!"); return(false); } if (this.milk < chosenCoffee.milk) { Console.WriteLine("Sorry, not enough milk!"); return(false); } if (this.beans < chosenCoffee.beans) { Console.WriteLine("Sorry, not enough coffee beans!"); return(false); } if (this.cups < 1) { Console.WriteLine("Sorry, not enough disposable cups of coffee!"); return(false); } else { Console.WriteLine("I have enough resources, making you a coffee!"); return(true); } }
public ICoffee CaptureAddOns(ICoffee coffee) { var done = false; while (!done) { DisplayAddOnMenu(); var optionSelected = Console.ReadLine(); if (optionSelected == "0") { done = true; } else { int.TryParse(optionSelected.ToString(), out int selected); if (Enum.IsDefined(typeof(AddOnType), selected)) { var addOnType = (AddOnType)selected; coffee = addOnFactory.Create(coffee, addOnType); } else { Console.WriteLine("Invalid option. Press any key to continue..."); Console.ReadKey(); continue; } } } return(coffee); }
public EspressoShotDecorator(ICoffee decoratedCoffee) { _decoratedCoffee = decoratedCoffee; Cost += .55M; decoratedCoffee.Ingredients.ForEach(x => Ingredients.Add(x)); Ingredients.Add("Espresso"); }
private void ShowMessageBoxCreateCoffee(ICoffee coffee) { string createdCoffeeMessage = "Coffee Created: " + coffee.Description + "\nCost: " + Math.Round(coffee.Cost, 2) + " euros"; MessageBox.Show(createdCoffeeMessage, "Coffee Ordered", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public IAddOnDecorator Create(ICoffee coffee, AddOnType addOnType) { switch (addOnType) { case AddOnType.Milk: return(new MilkDecorator(coffee)); case AddOnType.Chocolate: return(new ChocolateDecorator(coffee)); case AddOnType.Cinnamon: return(new CinnamonDecorator(coffee)); case AddOnType.WhippedCream: return(new WhippedCreamDecorator(coffee)); case AddOnType.Ice: return(new IceDecorator(coffee)); case AddOnType.Caramel: return(new CaramelDecorator(coffee)); case AddOnType.Water: return(new WaterDecorator(coffee)); default: throw new ArgumentException(nameof(addOnType)); } }
public void Test_Equals_NotOk() { ICoffee c1 = _factory.CreateCoffee("Espresso"); ICoffee c2 = _factory.CreateCoffee("Cappuccino"); Assert.IsFalse(c1.Equals(c2)); }
public void ConstructorShouldThrowArgumentNullException_WhenNullParameterIsPassed() { //Arrange ICoffee coffeeMock = null; //Act & Assert Assert.That(() => new FinalOrderViewModel(coffeeMock), Throws.InstanceOf <ArgumentNullException>()); }
public void CinnamonClass_Countructor_ShouldThrowArgumentNullExceptionWhenNoParameterIsProvided() { // Arrange ICoffee coffee = null; // Act & Assert Assert.That(() => new Cinnamon(coffee), Throws.ArgumentNullException.With.Message.Contains("coffee")); }
static void ShowCoffeeCreated(ICoffee coffee) { Console.Write( "\n" + "\nCoffee Created: {0}" + "\nCost: {1} euros" , coffee.Description, Math.Round(coffee.Cost, 2)); }
static ICoffee CreateCoffee(CoffeFactory factory, ICoffee coffee, string[] condimentsSelected) { foreach (string condiment in condimentsSelected) { coffee = factory.AddCondiment(coffee, condiment); //Creates the coffe with the selected condiments } return(coffee); }
public Milk(ICoffee coffee) { if (coffee == null) { throw new ArgumentNullException(nameof(coffee)); } this.coffee = coffee; }
public WhippedCream(ICoffee coffee) { if (coffee == null) { throw new ArgumentNullException(nameof(coffee)); } this.coffee = coffee; }
// Sequence of basic steps is implemented as template method. public void Brew(ICoffee coffee) { Grind(); coffee.Prepare(); TurnOnMachine(); Wait(); coffee.AddExtras(); Serve(); }
public override bool Equals(object obj) { if (obj is ICoffee) { ICoffee other = obj as ICoffee; return(Kind == other.Kind && Strength == other.Strength && Size == other.Size); } return(false); }
public FinalOrderViewModel(ICoffee coffee) { if (coffee == null) { throw new ArgumentNullException(); } this.coffee = coffee; this.FullDescription = coffee.FullDescription; this.Price = coffee.Cost(); }
private void addSoy_Click(object sender, EventArgs e) { if (currentCoffee != null) { currentCoffee = new Soy(currentCoffee); UpdateSelection(); } else { MessageBox.Show("Please select a coffee type first"); } }
public ICoffee AddCondiment(ICoffee aCoffee, string aType) { switch (aType) { case "Steamed Milk": return(AddSteamedMilk(aCoffee)); case "Mocha": return(AddMocha(aCoffee)); case "Soy": return(AddSoy(aCoffee)); case "Whip": return(AddWhip(aCoffee)); } throw new Exception(); }
static void Main(string[] args) { RandomNameGenerator rng = new RandomNameGenerator(); ICoffeeFactory factory = new CoffeeFactory(); for (int i = 0; i < 1000; i++) { ICoffee c1 = factory.CreateCoffee(nameof(Cappuccino)); c1.Serve(rng.GetRandomName()); ICoffee c2 = factory.CreateCoffee(nameof(Espresso)); c2.Serve(rng.GetRandomName()); ICoffee c3 = factory.CreateCoffee(nameof(LatteDoppio)); c3.Serve(rng.GetRandomName()); ICoffee c4 = factory.CreateCoffee(nameof(LatteGrande)); c4.Serve(rng.GetRandomName()); ICoffee c5 = factory.CreateCoffee(nameof(LatteTriplo)); c5.Serve(rng.GetRandomName()); } }
private void finishCreation_Click(object sender, EventArgs e) { if (currentCoffee != null) { string desc = currentCoffee.getDescription(); if (desc.Substring(desc.Length - 5, 5) == "with ") { beveragesSoldLb.Items.Add("Sold plain " + desc.Substring(0, desc.Length - 6) + " for " + currentCoffee.getCost()); } else { beveragesSoldLb.Items.Add("Sold " + desc.Substring(0, currentCoffee.getDescription().Length - 2) + " for " + currentCoffee.getCost()); } currentCoffee = null; } else { MessageBox.Show("There is no coffee selected."); } }
public MilkDecorator(ICoffee coffee) : base(coffee) { _description = "Milk"; _price = 4; }
public MilkDecorator(ICoffee coffee) : base(coffee) { }
public Mocha(ICoffee aCoffee) : base(aCoffee) { }
public ICoffee Execute(ICoffee coffee) { return coffee.AddMilk(); }
public SugarDecorator(ICoffee decoratedCoffee) { _decoratedCoffee = decoratedCoffee; }
public CoffeeCreamer(ICoffee coffeeToVend) : base(coffeeToVend) { this._coffeeToVend = coffeeToVend; }
public WhippedCreamDecorator(ICoffee decoratedCoffee) : base(decoratedCoffee) { }
public EspressoShotDecorator(ICoffee decoratedCoffee) : base(decoratedCoffee) { }
public ICoffee Execute(ICoffee coffee) { return coffee.AddSugar(); }
public CoffeeWrapper(ICoffee coffee) { this.Coffee = coffee; }
protected IngredientDecorator(ICoffee decoratedCoffee) { _decoratedCoffee = decoratedCoffee; }
public ICoffee Execute(ICoffee coffee) { return _func(coffee); }
public string asks4Coffee(ICoffee someone) { return($"{name} {lastName} asks for a coffee.\n{someone.prepareCoffee()}"); }
public CaramelDecorator(ICoffee coffee) { this.caramel = new Caramel(); this.Coffee = coffee; }
public MilkDecorator(ICoffee decoratedCoffee) { _decoratedCoffee = decoratedCoffee; }