public void StatIntDictTest()
    {
        PKMN.StatDict statDict = new PKMN.StatDict();
        statDict[PKMN.Stat.HP]      = 12;
        statDict[PKMN.Stat.ATTACK]  = 34;
        statDict[PKMN.Stat.DEFENSE] = 56;
        statDict[PKMN.Stat.SPEED]   = 78;
        statDict[PKMN.Stat.SPECIAL] = 90;

        PKMN.StatDict statDictSame = new PKMN.StatDict();
        statDictSame[PKMN.Stat.SPECIAL] = 90;
        statDictSame[PKMN.Stat.SPEED]   = 78;
        statDictSame[PKMN.Stat.DEFENSE] = 56;
        statDictSame[PKMN.Stat.ATTACK]  = 34;
        statDictSame[PKMN.Stat.HP]      = 12;

        PKMN.StatDict statDictShuffled = new PKMN.StatDict();
        statDictShuffled[PKMN.Stat.HP]      = 78;
        statDictShuffled[PKMN.Stat.ATTACK]  = 12;
        statDictShuffled[PKMN.Stat.DEFENSE] = 90;
        statDictShuffled[PKMN.Stat.SPEED]   = 34;
        statDictShuffled[PKMN.Stat.SPECIAL] = 56;

        Assert.AreEqual(statDict, statDict);
        Assert.AreEqual(statDict, statDictSame);
        Assert.AreEqual(statDict.GetHashCode(), statDictSame.GetHashCode());

        Assert.AreNotEqual(statDict, statDictShuffled);
        Assert.AreNotEqual(statDict.GetHashCode(), statDictShuffled.GetHashCode());
    }
Esempio n. 2
0
    public void PokemonEntryTest()
    {
        // Make sure trying to create an invalid entry results in an error.
        Assert.Throws <ArgumentOutOfRangeException>(
            delegate {
            new PKMN.Database.PokemonEntry(PKMN.Species.CASTFORM, PKMN.Game.NONE, "Sunny");
        }
            );
        Assert.Throws <ArgumentOutOfRangeException>(
            delegate {
            new PKMN.Database.PokemonEntry(PKMN.Species.CASTFORM, PKMN.Game.BLACK2, "Not a form");
        }
            );

        PKMN.Database.PokemonEntry pokemonEntry = new PKMN.Database.PokemonEntry(PKMN.Species.STUNFISK, PKMN.Game.BLACK2, "");

        Assert.AreEqual(pokemonEntry.Species, PKMN.Species.STUNFISK);
        Assert.AreEqual(pokemonEntry.SpeciesName, "Stunfisk");
        Assert.AreEqual(pokemonEntry.Game, PKMN.Game.BLACK2);
        Assert.AreEqual(pokemonEntry.Category, "Trap");
        Assert.AreEqual(pokemonEntry.Form, "Standard");

        // Just make sure this works
        string pokedexEntry = pokemonEntry.PokedexEntry;

        Assert.That(pokemonEntry.Height, Is.EqualTo(0.7).Within(0.0001));
        Assert.That(pokemonEntry.Weight, Is.EqualTo(11.0).Within(0.0001));
        Assert.That(pokemonEntry.ChanceMale, Is.EqualTo(0.5).Within(0.0001));
        Assert.That(pokemonEntry.ChanceFemale, Is.EqualTo(0.5).Within(0.0001));
        Assert.IsFalse(pokemonEntry.HasGenderDifferences);
        Assert.AreEqual(pokemonEntry.BaseFriendship, 70);
        Assert.AreEqual(
            pokemonEntry.Types,
            new PKMN.TypeEnumPair(PKMN.Type.GROUND, PKMN.Type.ELECTRIC)
            );
        Assert.AreEqual(
            pokemonEntry.Abilities,
            new PKMN.AbilityEnumPair(PKMN.Ability.STATIC, PKMN.Ability.LIMBER)
            );
        Assert.AreEqual(pokemonEntry.HiddenAbility, PKMN.Ability.SAND_VEIL);
        Assert.AreEqual(
            pokemonEntry.EggGroups,
            new PKMN.EggGroupEnumPair(PKMN.EggGroup.WATER1, PKMN.EggGroup.INDETERMINATE)
            );

        PKMN.StatDict baseStats = pokemonEntry.BaseStats;
        Assert.AreEqual(baseStats[PKMN.Stat.HP], 109);
        Assert.AreEqual(baseStats[PKMN.Stat.ATTACK], 66);
        Assert.AreEqual(baseStats[PKMN.Stat.DEFENSE], 84);
        Assert.AreEqual(baseStats[PKMN.Stat.SPEED], 32);
        Assert.AreEqual(baseStats[PKMN.Stat.SPECIAL_ATTACK], 81);
        Assert.AreEqual(baseStats[PKMN.Stat.SPECIAL_DEFENSE], 99);

        PKMN.StatDict evYields = pokemonEntry.EVYields;
        Assert.AreEqual(evYields[PKMN.Stat.HP], 2);
        Assert.AreEqual(evYields[PKMN.Stat.ATTACK], 0);
        Assert.AreEqual(evYields[PKMN.Stat.DEFENSE], 0);
        Assert.AreEqual(evYields[PKMN.Stat.SPEED], 0);
        Assert.AreEqual(evYields[PKMN.Stat.SPECIAL_ATTACK], 0);
        Assert.AreEqual(evYields[PKMN.Stat.SPECIAL_DEFENSE], 0);

        Assert.AreEqual(pokemonEntry.ExperienceYield, 165);
        Assert.AreEqual(pokemonEntry.GetExperienceAtLevel(50), 125000);
        Assert.AreEqual(pokemonEntry.GetLevelAtExperience(200000), 58);
        Assert.Greater(pokemonEntry.LevelupMoves.Count, 0);
        Assert.Greater(pokemonEntry.TMHMMoves.Count, 0);
        Assert.Greater(pokemonEntry.EggMoves.Count, 0);
        Assert.Greater(pokemonEntry.TutorMoves.Count, 0);
        Assert.AreEqual(pokemonEntry.Forms.Count, 1);
        Assert.AreEqual(pokemonEntry.Evolutions.Count, 0);

        Assert.IsTrue(System.IO.File.Exists(pokemonEntry.GetIconFilepath(false)));
        Assert.IsTrue(System.IO.File.Exists(pokemonEntry.GetIconFilepath(true)));
        Assert.IsTrue(System.IO.File.Exists(pokemonEntry.GetSpriteFilepath(false, false)));
        Assert.IsTrue(System.IO.File.Exists(pokemonEntry.GetSpriteFilepath(false, true)));
        Assert.IsTrue(System.IO.File.Exists(pokemonEntry.GetSpriteFilepath(true, false)));
        Assert.IsTrue(System.IO.File.Exists(pokemonEntry.GetSpriteFilepath(true, true)));
    }