示例#1
0
    public static void TestTrain()
    {
        int     age = 22;
        Trainer bob = new Trainer("Bob", age);

        string whoami_target = "I'm a pokemon Trainer !\n";
        string desc_target   = "My name is Bob, I'm 22 and I have 0 Pokemon !\n";

        string whoami_res = Output(() => { bob.WhoAmI(); });
        string desc_res   = Output(() => { bob.Describe(); });

        string display_target = "My Pokemon are :\n- a\n- b\n";


        Tests.Assert(whoami_target == whoami_res, "Got [" + whoami_res + "] instead of " + whoami_target);
        Tests.Assert(desc_target == desc_res, "Got " + desc_res + "instead of " + desc_target);

        bob.Birthday();

        Tests.Assert(bob.Age == age + 1, "Got age " + bob.Age + " after birthday instead of " + age + 1);

        bob.CatchAPokemon(new Pokemon("a", 100, 100, Pokemon.Poketype.FIRE));
        bob.CatchAPokemon(new Pokemon("b", 100, 100, Pokemon.Poketype.FIRE));

        string display_res = Output(() => { bob.MyPokemon(); });

        Tests.Assert(bob.NumberOfPokemon() == 2, "Got count of " + bob.NumberOfPokemon() + " instead of two");
        Tests.Assert(display_res == display_target, "Got " + display_res + " instead of " + display_target);
    }