示例#1
0
    /**
     *	Unit test of the RemovePlayer function
     */
    void TestRemovePlayer()
    {
        print("TestRemovePlayer...");
        PlayerColor newPlayer;

        string[]      data;
        List <string> trueData;

        CreateFile();

        //Empty file
        ColorFileManager.RemovePlayer("Test", path);

        //Player not in the file
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        newPlayer = new PlayerColor("Test2", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);

        ColorFileManager.RemovePlayer("Test3", path);
        data     = System.IO.File.ReadAllLines(path);
        trueData = FileWithoutBlank(data);
        Assert.AreEqual(3, trueData.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 3!"));

        //Player in file
        ColorFileManager.RemovePlayer("Test", path);
        data     = System.IO.File.ReadAllLines(path);
        trueData = FileWithoutBlank(data);
        Assert.AreEqual(2, trueData.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!"));

        DeleteFile();
    }
    /**
     *	Delete a player in the csv file and go back to player selection screen
     */
    public void DeletePlayer()
    {
        selectSound.Play();
        string player = dropdown.options[dropdown.value].text;

        if (!isDefaultPlayer(player))
        {
            ColorFileManager.RemovePlayer(player);
        }
        DisabledPlayersSettingsScreen();
        EnabledPlayerMenu();
    }