Example #1
0
 public void CheckReset(object sender, LevelUpEventArgs e)
 {
     if (e.NewLevel == MAX_LEVEL_BEFORE_RESTART)
     {
         StatRecorder.Reset();
         LevelManager.Reset();
         WeaponController.Reset();
         LifeController.Reset();
     }
 }
        public void StatRecorderDeletes()
        {
            StatRecorder r = new StatRecorder();

            r.AddValue(RootStat.Agility.ToString(), new StatValue(StatLevels.Black, 3));
            r.AddValue(RootStat.Forte.ToString(), new StatValue(StatLevels.Black, 4));

            Assert.IsNotNull(r.GetValue(RootStat.Forte));
            Assert.IsTrue(r.DelValue(RootStat.Forte));
            Assert.IsNull(r.GetValue(RootStat.Forte));
            Assert.IsNotNull(r.GetValue(RootStat.Agility));
        }
        public void StatRecorderAddsGets()
        {
            StatRecorder r = new StatRecorder();

            r.AddValue(RootStat.Agility.ToString(), new StatValue(StatLevels.Black, 3));
            r.AddValue(RootStat.Forte.ToString(), new StatValue(StatLevels.Black, 4));

            Assert.IsTrue(r.HasValue(RootStat.Agility));
            Assert.IsNotNull(r.GetValue(RootStat.Forte));
            Assert.AreEqual(r.GetValue(RootStat.Forte).dice, 4);
            Assert.AreEqual(r.GetValue(RootStat.Agility).dice, 3);
        }
Example #4
0
        public void DoTest(Request request)
        {
            WriteLine("codec, success, uncompressed size, compressed size, compression ratio, compression ticks, decompression ticks, filesize, filename,");

            var stats   = new Stats();
            var results = new List <Result>();

            foreach (var dataSet in GetItems(request))
            {
                var codec    = dataSet.Item1;
                var data     = dataSet.Item2;
                var filename = dataSet.Item3;

                try
                {
                    var result = TestDataRoundtrip(request, codec, data);
                    result.Codec = codec;
                    if (String.IsNullOrEmpty(codec.CodecName))
                    {
                        codec.CodecName = codec.GetType().Name;
                    }
                    codec.CodecName = codec.CodecName.Replace("Codec", "");

                    result.DataFilename = filename;
                    results.Add(result);

                    if (!result.Success)
                    {
                        DumpResult(result, codec, filename);
                        stats.Failed++;
                    }
                    else
                    {
                        stats.Succeeded++;
                        stats.TotalBytesData  += (ulong)result.UncompressedLength;
                        stats.TotalCompressed += (ulong)result.CompressedLength;
                    }
                    if (!request.ShowOnlyErrors && result.Success)
                    {
                        DumpResult(result, codec, filename);
                    }
                }
                // public bool TrapErrors { get; set; }
                catch (Exception ex)
                {
                    stats.Failed++;
                    var length = 0L;
                    if (!String.IsNullOrEmpty(filename) && File.Exists(filename))
                    {
                        length = new FileInfo(filename).Length;
                    }
                    WriteLine($"EXCEPTION: {filename,30} ({length,10}): " + ex);
                    if (!request.TrapErrors)
                    {
                        throw;
                    }
                }

                if (Console.KeyAvailable)
                {
                    while (Console.KeyAvailable)
                    {
                        Console.ReadKey(true);
                    }
                    DumpStats(stats);
                }
            }
            // final summary
            DumpStats(stats);

            // final table
            DumpTable(results, stats);

            // anything logged
            StatRecorder.DumpLog(OutputWriter);
        }