예제 #1
0
파일: Tester.cs 프로젝트: sillsdev/libcom
    public static void Main(string[] args)
    {
        System.Console.WriteLine("Starting Tester.");

        System.Console.WriteLine("Writing Hello on wall.");
        Wall wall = new Wall();
        wall.writeBSTROnWall("Hello");
        System.Console.WriteLine("Writing Brrrrr! on wall.");
        wall.writeBSTROnWall("Brrrrr!");
        System.Console.WriteLine("Reading wall:");
        string wallContents = "overwrite me";
        wallContents = wall.readWallBSTR();
        System.Console.WriteLine("Wall says: " + wallContents);
        System.Console.WriteLine("Again, Wall says: '" + wall.readWallBSTR() + "'.");

        System.Console.WriteLine("\n\nDoing Bag-Ball test");
        //TODO What if I create it something like: IBag bag = (IBall) Factory.BagClass();  Eberhard might have said I was supposed to be doing this sort of thing that way.
        Bag bag = new Bag();
        Ball ball = (Ball) bag.ProvideBall(); // TODO what if I cast it as an IBall rather than Ball

        long distance_rolled;
        distance_rolled = ball.roll(2);
        System.Console.WriteLine("Rolling ball by 2. Accumulated distance: {0} (should say 2)", distance_rolled);
        if (distance_rolled != 2) {
            System.Console.WriteLine("Tester.exe: Error, distance wasn't correct. Exiting.");
            Environment.Exit(-1);
        }
        bag.InspectBall(ball);
        distance_rolled = ball.roll(9);
        System.Console.WriteLine("Rolling ball by 9. Accumulated distance: {0} (should say 14)", distance_rolled);
        if (distance_rolled != 14) {
            System.Console.WriteLine("Tester.exe: Error, distance wasn't correct. Exiting.");
            Environment.Exit(-1);
        }
    }