Exemple #1
0
        public static void Map023Test()
        {
            Common(
                MapFileTestItemGenerator.GenerateMap023Data(),
                "Map023.mps");

            Assert.True(true);
        }
Exemple #2
0
        public static void ToBinaryMap023Test()
        {
            MapFileTestItemGenerator.OutputMapFile();
            var map023Data    = MapFileTestItemGenerator.GenerateMap023Data();
            var map023DataBuf = map023Data.ToBinary();

            using (var fs = new FileStream($@"{MapFileTestItemGenerator.TestWorkRootDir}\Map023.mps", FileMode.Open))
            {
                var length = (int)fs.Length;
                // ファイルサイズが規定でない場合誤作動防止の為テスト失敗にする
                Assert.AreEqual(length, 6615);

                var fileData = new byte[length];
                fs.Read(fileData, 0, length);

                // binデータ出力用
                var builder = new StringBuilder();
                foreach (var str in fileData.Select((s, index) => $"=\"[{index}] = {{byte}} {s}\""))
                {
                    builder.AppendLine(str);
                }

                var result = builder.ToString();
                Console.WriteLine(result);

                builder = new StringBuilder();
                foreach (var str in map023DataBuf.Select((s, index) => $"=\"[{index}] = {{byte}} {s}\""))
                {
                    builder.AppendLine(str);
                }

                result = builder.ToString();
                Console.WriteLine(result);

                for (var i = 0; i < map023DataBuf.Length; i++)
                {
                    if (i == fileData.Length)
                    {
                        Assert.Fail(
                            $"データ長が異なります。(期待値:{fileData.Length}, 実際:{map023DataBuf.Length})");
                    }

                    if (fileData[i] != map023DataBuf[i])
                    {
                        Assert.Fail(
                            $"offset: {i} のバイナリが異なります。(期待値:{fileData[i]}, 実際:{map023DataBuf[i]})");
                    }
                }

                if (fileData.Length != map023DataBuf.Length)
                {
                    Assert.Fail(
                        $"データ長が異なります。(期待値:{fileData.Length}, 実際:{map023DataBuf.Length})");
                }
            }
        }