示例#1
0
        public void BenchmarkZoneTextPersister()
        {
            int time = Benchmark.Run("StreamReader.ReadToEnd", 5, () =>
            {
                const string want = @"
-------------------
|  ?  |  ?  |  ?  |
-------------------
|  ?  |     |     |
-------------------
|     |  ?  |     |
-------------------
";
                var persister     = SetupPersister.SetupTestFileTextPersister();
                persister.Save(want);

                string got = persister.Load <string>();
                persister.Delete();
            });

            int benchTime = 8;

            Assert.True(time < benchTime,
                        "time per iteration was: " + time + "ms which is greater than expected time of: " + benchTime + "ms");
        }
示例#2
0
        public void BenchmarkSerializeThenPersistZoneMap()
        {
            var want = SetupZoneMap.SetupBigGrid();

            var    serializer = new ZoneMapSerializer();
            var    persister  = SetupPersister.SetupTestFileTextPersister();
            string mapName    = SetupPersister.GetCurrentMethodName();

            persister.FileName = mapName;

            int time = Benchmark.Run("StreamReader.ReadToEnd", 5, () =>
            {
                string json = serializer.Serialize(want);
                persister.Save(json);

                string got = persister.Load <string>();
                persister.Delete();
                var map = serializer.DeSerialize(got);
            });

            int benchTime = 180;

            Assert.True(time < benchTime,
                        "time per iteration was: " + time + "ms which is greater than expected time of: " + benchTime + "ms");
        }
示例#3
0
        public void SaveCanPersistTextToFile()
        {
            const string want      = @"
-------------------
|  ?  |  ?  |  ?  |
-------------------
|  ?  |     |     |
-------------------
|     |  ?  |     |
-------------------
";
            var          persister = SetupPersister.SetupTestFileTextPersister();

            persister.Save(want);

            string got = persister.Load <string>();

            Assert.Equal(want, got);
        }