Ejemplo n.º 1
0
    public static void Main(string[] args)
    {
        System.Console.WriteLine("Bakery + Jar CCW COM test.");

        //IBakery Bakery = (IBakery) Factory.BakeryClass(); // TODO should be using this line. (?really?)
        Bakery bakery = new Bakery();
        Kitchen.Jar jar = new Kitchen.Jar();

        System.Console.WriteLine("Number of cookies in jar: " + jar.GetNumberCookies());
        System.Console.WriteLine("Baking 8 cookies.");
        bakery.bakeCookies(8, jar);

        System.Console.WriteLine("Number of cookies in jar: " + jar.GetNumberCookies());
        System.Console.WriteLine("Baking 3 cookies.");
        bakery.bakeCookies(3, jar);

        int totalCookiesBaked = bakery.getNumberCookiesBaked();
        if (11 != totalCookiesBaked) {
            System.Console.WriteLine("Error: Did not bake correct number of cookies.");
            throw new Exception("error"); // TODO right way
        } else {
            System.Console.WriteLine("Successfully baked a total of " + totalCookiesBaked + " cookies.");
        }
    }