public void AddItem_IsAdded(string name, string amount, string description, string price, string category) { IEnumerable <IItem> expected = new List <IItem> { new ItemByNumber(MockAssortementRepsotory.GetLastId() + 1, Int32.Parse(amount), name, description, Decimal.Parse(price), Decimal.Parse(price) * Int32.Parse(amount), Category.Drinks) }; addItemBLL.AddItem(name, amount, description, price, category); Assert.IsTrue(expected.SequenceEqual(new List <IItem> { MockAssortementRepsotory.GetItemById(MockAssortementRepsotory.GetLastId()) }, itemComparer)); }
/// <summary> /// Add new Item to assortement /// </summary> /// <param name="name"></param> /// <param name="amount"></param> /// <param name="description"></param> /// <param name="price"></param> /// <param name="category"></param> public void AddItem(string name, string amount, string description, string price, string category) { if (IsIntResult(amount, out int intResult) && IsPriceCorrect(price, out decimal parsedPrice) && IsCategoryType(category, out Category parsedCategory)) { ((IList <IItem>)MockAssortementRepsotory.Assortement).Add(new ItemByNumber(MockAssortementRepsotory.GetLastId() + 1, intResult, name, description, parsedPrice, parsedPrice, parsedCategory)); Console.WriteLine("New item has been added"); } else if (IsDoubleResult(amount, out double doubleResult) && IsPriceCorrect(price, out parsedPrice) && IsCategoryType(category, out parsedCategory)) { ((IList <IItem>)MockAssortementRepsotory.Assortement).Add(new ItemByWeight(MockAssortementRepsotory.GetLastId() + 1, doubleResult, name, description, parsedPrice, parsedPrice, parsedCategory)); Console.WriteLine("New item has been added"); } else { Console.WriteLine("Wrong parameters"); } }