Exemple #1
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();
    }
Exemple #2
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
        PlayerData newPlayer = new PlayerData("Test", 1, 2, 3, 4, 0, 0, 0, 1, 0);

        DataFileManager.AddNewPlayer(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
        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!"));

        //Check the first line of the file
        string firstline = "name;id;randomMode;platform5;platform6;platform7;platform10;spikes;catcher;evilBlock;evilSaw";

        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();
    }
Exemple #3
0
 /**
  *	Create a data file for the tests
  */
 void CreateFile()
 {
     if (!File.Exists(path))
     {
         File.Create(path).Dispose();
     }
     DataFileManager.ResetFile(path);
 }