public void GivenOwnerHasBakedNewProductWithoutNameAndPrice() { string jsonResponse = requestHelper.ExecutePostProductRequest(string.Empty, null); BakeryProduct bakeryProduct = DeserializeJSON_ToBakeryProduct.GetAddedBakeryProductFromPostRequest(jsonResponse); ScenarioContext.Current.Set(bakeryProduct.Id, "id"); }
/// <summary> /// Creates an account in the bank /// </summary> /// <param name="customerName">Customer's name</param> /// <param name="customerAddress">Customer's address</param> /// <param name="customerEmailAddress">Customer's email address</param> /// <param name="customerBankAccountNumber">Bank account number of the customer</param> /// <param name="bakeryProduct">Bakery product type</param> /// <param name="numberOfOrder">Quantity of the order</param> /// <returns>Newly created order</returns> /// <exception cref="ArgumentNullException" /> public static Bakery CreateBakery (BakeryProduct bakeryProduct, string customerName, string customerEmailAddress, string customerBankAccountNumber, int numberOfOrder = 0) { if (string.IsNullOrEmpty(customerEmailAddress) || string.IsNullOrWhiteSpace(customerEmailAddress)) { throw new ArgumentNullException ("emailAddress", "Email Address is required!"); } var a1 = new Bakery { CustomerName = customerName, CustomerEmailAddress = customerEmailAddress, CustomerBankAccountNumber = customerBankAccountNumber, BakeryProduct = bakeryProduct, NumberOfOrder = numberOfOrder }; if (numberOfOrder > 0) { a1.Order(numberOfOrder); } db.Bakeries.Add(a1); db.SaveChanges(); return(a1); }
public void GivenOwnerHasBakedProductThatAlreadyExists() { string jsonResponse = requestHelper.ExecutePostProductRequest("Bread", "3.45"); BakeryProduct bakeryProduct = DeserializeJSON_ToBakeryProduct.GetAddedBakeryProductFromPostRequest(jsonResponse); ScenarioContext.Current.Set(bakeryProduct.Id, "id"); }
public void ThenCustomerCanBuyNewProduct() { string jsonResponse = requestHelper.ExecuteGetSpecificProductRequest(ScenarioContext.Current["id"].ToString()); BakeryProduct bakeryProduct = DeserializeJSON_ToBakeryProduct.GetAddedBakeryProductFromGetSpecificOrNewestIdRequest(jsonResponse); Assert.AreEqual(ScenarioContext.Current["id"].ToString(), bakeryProduct.Id); }
public void GivenOwnerHasBakedNewProductThatCosts(string name, string price) { string jsonResponse = requestHelper.ExecutePostProductRequest(name, price); BakeryProduct bakeryProduct = DeserializeJSON_ToBakeryProduct.GetAddedBakeryProductFromPostRequest(jsonResponse); ScenarioContext.Current.Set(bakeryProduct.Id, "id"); }
public void WhenCustomerAsksForMostFreshBakeryGood() { string jsonResponse = requestHelper.Client.Execute(requestHelper.GetNewestProductRequest).Content; BakeryProduct bakeryProduct = DeserializeJSON_ToBakeryProduct.GetAddedBakeryProductFromGetSpecificOrNewestIdRequest(jsonResponse); ScenarioContext.Current.Set(bakeryProduct.Id, "id"); }
public void ThenBakeryGoodWithNameAndPriceIsVisibleIsVisible(string name, string price) { string jsonResponse = requestHelper.ExecuteGetSpecificProductRequest(ScenarioContext.Current["id"].ToString()); BakeryProduct bakeryProduct = DeserializeJSON_ToBakeryProduct.GetAddedBakeryProductFromGetSpecificOrNewestIdRequest(jsonResponse); Assert.AreEqual(ScenarioContext.Current["id"].ToString(), bakeryProduct.Id); Assert.AreEqual(name, bakeryProduct.Name); Assert.AreEqual(price, bakeryProduct.Price); }
public async void LoadBakeryProduct(Guid?bakeryProductId) { if (bakeryProductId != null) { BakeryProducts = new ObservableCollection <BakeryProduct>(); var bakeryProduct = await _context.BakeryProducts .FirstOrDefaultAsync(f => f.Id == bakeryProductId); ShopBakeryProduct = bakeryProduct; _bakeryProduct = bakeryProduct; BakeryProducts.Add(bakeryProduct); } }
public void Craft() { var products = _context.BakeshopProducts.ToList(); var ingredients = Formula.FormulaIngredients.Select(fi => fi.Ingredient); if (string.IsNullOrEmpty(Quantity)) { MessageBox.Show($"You have to fill quantity", "Exception", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (int.Parse(Quantity) == 00) { MessageBox.Show($"You have to fill quantity with valid values", "Exception", MessageBoxButton.OK, MessageBoxImage.Information); return; } foreach (var ingredient in ingredients) { var product = products.FirstOrDefault(p => p.Name == ingredient.Name); if (product == null) { MessageBox.Show($"There are no {ingredient.Name} found", "Exception", MessageBoxButton.OK, MessageBoxImage.Warning); return; } switch (ingredient.UomType) { case UomTypes.Killograms: case UomTypes.Litres: case UomTypes.Pcs: if ((product.Quantity - ingredient.Quantity * int.Parse(Quantity)) >= 0) { product.Quantity -= ingredient.Quantity * int.Parse(Quantity); } break; case UomTypes.Gramms: if ((product.Quantity - (ingredient.Quantity * double.Parse(Quantity)) / 1000) >= 0) { var gramms = (double.Parse(Quantity) * ingredient.Quantity) / 1000; product.Quantity -= gramms; } break; } } var bakeryProduct = new BakeryProduct { ExpirationDate = DateTime.UtcNow.AddDays(2), IsSold = true, Name = Formula.Name, Price = Formula.Price, Quantity = int.Parse(Quantity), UomType = UomTypes.Pcs }; _context.BakeryProducts.Add(bakeryProduct); _context.SaveChanges(); MessageBox.Show($"Crafted", "Exception", MessageBoxButton.OK, MessageBoxImage.Information); CloseAction(); }