Exemple #1
0
 public void T201_FileFormatException()
 {
     var e = new FileFormatException();
     Assert.NotEmpty(e.Message);
     Assert.Null(e.SourceUri);
     Assert.Null(e.InnerException);
 }
Exemple #2
0
 public void T204_FileFormatException()
 {
     var partUri = new Uri("/idontexist.xml", UriKind.Relative);
     var e = new FileFormatException(partUri, "Test");
     Assert.Equal("Test", e.Message);
     Assert.Same(partUri, e.SourceUri);
     Assert.Null(e.InnerException);
 }
Exemple #3
0
 public void T203A_FileFormatException()
 {
     Uri partUri = null;
     var e = new FileFormatException(partUri);
     Assert.NotEmpty(e.Message);
     Assert.Null(e.SourceUri);
     Assert.Null(e.InnerException);
 }
Exemple #4
0
 public void T202_FileFormatException()
 {
     var e2 = new IOException("Test");
     var e = new FileFormatException("Test", e2);
     Assert.Equal("Test", e.Message);
     Assert.Null(e.SourceUri);
     Assert.Same(e2, e.InnerException);
 }
Exemple #5
0
 public void T205_FileFormatException()
 {
     var partUri = new Uri("/idontexist.xml", UriKind.Relative);
     var e2 = new IOException("Test");
     var e = new FileFormatException(partUri, e2);
     Assert.NotEmpty(e.Message);
     Assert.Same(partUri, e.SourceUri);
     Assert.Same(e2, e.InnerException);
 }
Exemple #6
0
 public void T205A_FileFormatException()
 {
     Uri partUri = null;
     var e2 = new IOException("Test");
     var e = new FileFormatException(partUri, e2);
     Assert.NotEmpty(e.Message);
     Assert.Null(e.SourceUri);
     Assert.Same(e2, e.InnerException);
 }
Exemple #7
0
        /// <summary>
        /// ki2形式のファイルを読み込みます。
        /// </summary>
        private KifuObject LoadKi2(KifuHeader header, Board board)
        {
            // 先にリスト化しないと、ConvertMoveでエラーがあった時に
            // ファイルを最後までパースしなくなります。
            var moveList = ParseMoveLinesKi2().ToList();
            var bmoveList = board.ConvertMove(moveList);

            Exception error = null;
            if (moveList.Count() != bmoveList.Count())
            {
                if (moveList.Count() - 1 != bmoveList.Count())
                {
                    error = new FileFormatException(
                        string.Format(
                            "{0}手目の'{1}'を正しく処理できませんでした。",
                            bmoveList.Count() + 1,
                            moveList[bmoveList.Count()]));
                }
                else
                {
                    error = new FileFormatException(
                        "最終手が反則で終わっています。");
                }
            }

            return new KifuObject(header, board, bmoveList, error);
        }