Пример #1
0
    /**
     *	Unit test of the ListOfPlayers function
     */
    void TestListOfPlayers()
    {
        print("TestListOfPlayers...");
        List <string> playerList;
        PlayerColor   newPlayer;

        CreateFile();

        //Empty list
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(0, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 0!"));

        //Add a player
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(1, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 1!"));

        //Add an other player
        newPlayer = new PlayerColor("Test2", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(2, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!"));

        //Edit the first player
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(2, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!"));

        DeleteFile();
    }
Пример #2
0
    /**
     *	Unit test of the FindColors function
     */
    void TestFindColors()
    {
        print("TestFindColors...");
        Dictionary <string, Color> data;
        PlayerColor newPlayer;

        CreateFile();

        //Empty file
        data = ColorFileManager.FindColors("Test", path);
        Assert.AreEqual(null, data, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Data should not exist"));

        //Add a player
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        data = ColorFileManager.FindColors("Test", path);
        Assert.AreEqual(anger, data["Anger"], string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Wrong color!"));

        //Add an other player
        newPlayer = new PlayerColor("Test", surprise, anger, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        newPlayer = new PlayerColor("Test2", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        data = ColorFileManager.FindColors("Test", path);
        Assert.AreEqual(surprise, data["Anger"], string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Wrong color!"));

        DeleteFile();
    }
Пример #3
0
    /**
     *	Unit test of the ResetFile function
     */
    void TestResetFile()
    {
        print("TestResetFile...");
        string[]      data;
        List <string> trueData;

        CreateFile();

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

        //Add a player
        PlayerColor newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);

        ColorFileManager.EditPlayer(newPlayer, 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!"));

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

        //Check the first line of the file
        string firstline = "name;angerR;angerG;angerB;surpriseR;surpriseG;surpriseB;joyR;joyG;joyB;sadnessR;sadnessG;sadnessB";

        Assert.AreEqual(firstline, data[0], string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Invalid firstline!"));

        DeleteFile();
    }
Пример #4
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();
    }
    /**
     *	Set colors for the player in the csv file
     */
    public void SetPlayer()
    {
        selectSound.Play();
        Dictionary <string, Color> playerColor = GUIColorPickerController.GetEmotionColors();
        PlayerColor newPlayer = new PlayerColor(dropdown.options[dropdown.value].text, playerColor["Anger"], playerColor["Surprise"], playerColor["Joy"], playerColor["Sadness"]);

        ColorFileManager.EditPlayer(newPlayer);
        DisabledPlayersSettingsScreen();
        EnabledPlayerMenu();
    }
    /**
     *	Add a new player with his colors in the csv file
     */
    public void AddPlayer()
    {
        selectSound.Play();
        string player = inputField.GetComponent <InputField>().text;

        if (player.Length != 0)
        {
            Dictionary <string, Color> playerColor = GUIColorPickerController.GetEmotionColors();
            PlayerColor newPlayer = new PlayerColor(player, playerColor["Anger"], playerColor["Surprise"], playerColor["Joy"], playerColor["Sadness"]);
            ColorFileManager.EditPlayer(newPlayer);
        }
        DisabledPlayersSettingsScreen();
        EnabledPlayerMenu();
    }