Beispiel #1
0
    public void testCSVWriter()
    {
        csgoParser parser = new csgoParser(pathMirageDemo);

        parser.ParseAllRounds();
        Player p = parser.Players[0];
        string header;
        string secondLine;
        string header2;
        string secondLine2;
        int    round       = 1;
        Player illegalName = parser.Players[5];

        parser.SaveToCSV(p, round, outputPath);
        parser.SaveToCSV(illegalName, round, outputPath);
        parser.saveOnlyKillFeed(outputPath);

        string[] files            = Directory.GetFiles(outputPath, "*.csv", SearchOption.AllDirectories);
        string[] filePlayerPath   = files.Where(f => f.ContainsAll(p.Name, round.ToString())).ToArray();
        string[] fileKillfeedPath = files.Where(f => f.ContainsAll("killFeed", round.ToString())).ToArray();

        //directory is created and file is saved there
        Assert.IsTrue(Directory.Exists(outputPath));
        Assert.IsNotEmpty(files);
        Assert.IsNotEmpty(filePlayerPath);
        Assert.IsNotEmpty(fileKillfeedPath);

        using (StreamReader reader = new StreamReader(filePlayerPath[0]))
        {
            header = reader.ReadLine();
            //file doesnt end after header
            Assert.IsFalse(reader.EndOfStream);
            secondLine = reader.ReadLine();
        }

        using (StreamReader reader = new StreamReader(fileKillfeedPath[0]))
        {
            header2 = reader.ReadLine();
            //file doesnt end after header
            Assert.IsFalse(reader.EndOfStream);
            secondLine2 = reader.ReadLine();
        }

        int amountOfCommataInValues = secondLine.Count(f => f == ',');
        int amountOfCommataInHeader = header.Count(f => f == ',');

        //header is written correctly
        Assert.IsTrue(header.ContainsAll("ticks", "posX", "posY", "posZ"));

        Assert.AreEqual(amountOfCommataInHeader, amountOfCommataInValues);
        Assert.AreEqual(header2.Count(f => f == ','), secondLine2.Count(f => f == ','));
    }
    /// <summary>
    /// Saves the players' paths to a CSV
    /// </summary>
    /// <param name="args">replay file, and optional output folder</param>
    public static void Main(string[] args)
    {
        if (!AreProperArguments(args, out string saveFolder))
        {
            return;
        }

        string fileReplay = args[0];

        csgoParser parser = new csgoParser(fileReplay);

        Console.Write(parser.ToString());

        parser.ParseAllRounds();

        parser.SaveToCSV(saveFolder);

        Console.WriteLine("parsing finished");
        Console.Write(parser.GetEndGameStatsString());
    }
Beispiel #3
0
 public void saveToCSV(int round) => parser.SaveToCSV(round);