public void CreateTillamookMilkSucceeds()
        {
            IGroceryItemFactory abstractFactory = GroceryFactoryService.CreateGroceryItemFactory(GroceryProductFamily.Tillamook);
            IMilk milk = abstractFactory.ConstructMilk();

            Assert.IsTrue(milk.Brand == "Tillamook");
            Assert.IsTrue(milk.Description == "Milk");
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Coffee Shop!");

            // a list of all the orders for coffe in the coffee shop
            List <Coffee> orderList = new List <Coffee>()
            {
                new Cortado(),
                new Latte(),
                new BlackCoffee(),
            };

            Console.WriteLine("Here you Know the type of coffee," +
                              "its strength and price. ");
            foreach (var coffeeItem in orderList)
            {
                Console.WriteLine(coffeeItem.ToString());
            }
            Console.WriteLine("press any key to see the orderListMilk");
            Console.ReadLine();

            // List contaning objects that implements IMilk interface.
            var OrderListMilk = new List <IMilk>()
            {
                new Cortado(),
                new Latte(),
            };

            foreach (var coffeeItem in OrderListMilk)
            {
                Console.WriteLine($"The amount of Milk used is : {coffeeItem.MLMilk()}");
            }
            Console.WriteLine("press a key to see the typecast");
            Console.ReadLine();

            foreach (var coffeeItem in orderList)
            {
                if (coffeeItem is IMilk)
                {
                    // the item emplements the IMilk so i casted to this

                    IMilk cItem = coffeeItem as IMilk;
                    Console.WriteLine("Iam an IMilk object");

                    // the only method in IMilk is MLMilk so i print it out
                    Console.WriteLine($" Milk used is {cItem.MLMilk()}");
                }
                else
                {
                    Console.WriteLine("Iam not IMilk");
                }
            }
        }
예제 #3
0
파일: Mayo.cs 프로젝트: kkozmic/PaulTest
 public Mayo(IMilk milk, IQuestionableStuff questionableStuff)
 {
 }
 public Provolone(IMilk milk)
 {
 }
예제 #5
0
 public Provolone(IMilk milk)
 {
 }
예제 #6
0
 public Mayo(IMilk milk, IQuestionableStuff questionableStuff)
 {
 }