public static ISalesItem GetSalesItem(string name, decimal price, ItemType itemType)
        {
            ISalesItem item = new SalesItem(name, price);

            foreach (int flag in Enum.GetValues(typeof(ItemType)))
            {
                if ((flag & (int)itemType) == flag)
                {
                    item = (ISalesItem)Activator.CreateInstance(typeof(SalesItemTaxDecorator), new object[] { item, itemTaxLookup[(ItemType)flag] });
                }
            }

            return item;
        }
        public static ISalesItem GetSalesItem(string name, decimal price, ItemType itemType)
        {
            ISalesItem item = new SalesItem(name, price);

            foreach (int flag in Enum.GetValues(typeof(ItemType)))
            {
                if ((flag & (int)itemType) == flag)
                {
                    item = (ISalesItem)Activator.CreateInstance(typeof(SalesItemTaxDecorator), new object[] { item, itemTaxLookup[(ItemType)flag] });
                }
            }

            return(item);
        }
Example #3
0
 public void SalesItemGetTotalTest()
 {
     SalesItem target = new SalesItem("test item", 10M);
     decimal actual = target.GetTotal();
     Assert.AreEqual(10M, actual);
 }