示例#1
0
        public void Test_Load()
        {
            var serializer = new MockSerializer();

            serializer.Store =
                @"  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  1  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  1  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
";

            var area = serializer.Load("any.txt");

            Assert.IsTrue(area.Fields[5, 5].Enabled);
            Assert.IsTrue(area.Fields[7, 9].Enabled);
            Assert.IsFalse(area.Fields[9, 9].Enabled);
            Assert.IsFalse(area.Fields[0, 0].Enabled);
        }
示例#2
0
        public void Test_Save()
        {
            var area = new MaxGame.Models.GameArea();

            area.Fields[5, 5].Toggle();
            area.Fields[7, 9].Toggle();
            var serializer = new MockSerializer();

            Assert.IsTrue(serializer.Save(area, "any.txt"));
            var result   = serializer.Store;
            var expected =
                @"  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  1  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  1  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0
";

            Assert.AreEqual(expected, result);
        }