public void ダブルクォーテーションの不具合()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = bbb
                sei = He said, ""If only she were here.""
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("bbb", shomon.Mondaibun);

            /*			foreach (var item in shomon.MondaiWords)
                {
                    Console.WriteLine(item.Text);
                }*/

                Assert.AreEqual(@"He said, ""If only she were here.""", EmpDocument.先頭と末尾のダブルクォーテーションを取り除く(@"He said, ""If only she were here."""));

            //				var t = element.Body.GetAllItems().Where(x => "sei" == x.Name).First().Value;
            //				Assert.AreEqual(@"He said, ""If only she were here.""", t);
                CollectionAssert.AreEqual(new []
                {
                    new MondaiWord("He"),
                    new MondaiWord("said"),
                    new MondaiWord(","),
                    new MondaiWord(@""""),
                    new MondaiWord("If"),
                    new MondaiWord("only"),
                    new MondaiWord("she"),
                    new MondaiWord("were"),
                    new MondaiWord("here"),
                    new MondaiWord("."),
                    new MondaiWord(@""""),
                }, shomon.MondaiWords);
            }
        }
        public void GetMondaiDocumentTest()
        {
            var text = @"

            document
            {
            id = document1
            title = documentA

            daimon
            {
            id = daimon1
            title = ""daimonTitle""

            chumon
            {
            id = chumon1
            title = ""chumonTitle""

            shomon
            {
                id = shomon1
                mon
                {
                    Are these cameras?
                }

                sei
                {
                    No, they aren't.
                }

                word
                {
                    Yes,
                }
                word
                {
                    they are.
                }
            }
            }
            chumon
            {
            id = id2
            title = ""chumonTitle""

            shomon
            {
                id = shomon2
                mon
                {
                    Are these cameras?
                }

                sei
                {
                    No, they aren't.
                }

                word
                {
                    Yes,
                }
                word
                {
                    they are.
                }
            }
            }

            }

            daimon
            {
            id = id1
            title = ""daimonTitle""

            chumon
            {
            id = chumon2-2
            title = ""chumonTitle""

            shomon
            {
                id = shomon3
                mon
                {
                    Are these cameras?
                }

                sei
                {
                    No, they aren't.
                }

                word
                {
                    Yes,
                }
                word
                {
                    they are.
                }
            }
            }
            }
            }

            ";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);
                var userInfo = new EPuzzleUserInfo();

                Assert.AreEqual("document1", mondaiDocument.Id);

                var daimon = mondaiDocument.Items[0];

                Assert.AreEqual(@"""daimonTitle""", daimon.Name);
                Assert.IsNotEmpty(daimon.Id);

                var chumon = (Chumon)daimon.Items[0];
                Assert.AreEqual(@"""chumonTitle""", chumon.Name);
                Assert.IsNotEmpty(chumon.Id);

                Assert.AreEqual(1, chumon.Items.Count());
                var shomon = (Shomon)chumon.Items[0];
                Assert.AreEqual("shomon1", shomon.Id);
                Assert.AreEqual("Are these cameras?", shomon.Mondaibun);
                Assert.AreEqual("No, they aren't.", shomon.CorrectAnswers.First().Text);
                CollectionAssert.AreEquivalent(new [] { "No", ",", "they", "aren't", ".", "Yes,", "they are." }, shomon.MondaiWords.Select(x => x.Text).ToArray());

                Assert.AreEqual(TimeSpan.FromSeconds(6d), chumon.GetTimeLimit(userInfo));

                var daimon2 = (Daimon)mondaiDocument.Items[1];
                Assert.AreEqual("id1", daimon2.Id);

                var chumon2 = (Chumon)daimon.Items[1];
                Assert.AreEqual("id2", chumon2.Id);
            }
        }
        public void コロンに対応させる()
        {
            // They need two kind of support: economic and technical.
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = bbb
                sei = They need two kind of support: economic and technical.
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("bbb", shomon.Mondaibun);
                CollectionAssert.AreEqual(new []
                {
                    new MondaiWord("They"),
                    new MondaiWord("need"),
                    new MondaiWord("two"),
                    new MondaiWord("kind"),
                    new MondaiWord("of"),
                    new MondaiWord("support"),
                    new MondaiWord(":"),
                    new MondaiWord("economic"),
                    new MondaiWord("and"),
                    new MondaiWord("technical"),
                    new MondaiWord("."),
                }, shomon.MondaiWords);
            }
        }
        public void セミコロンを分割するテスト()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = bbb
                sei = We stopped talking; otherwise
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("bbb", shomon.Mondaibun);
                CollectionAssert.AreEqual(new []
                {
                    new MondaiWord("We"),
                    new MondaiWord("stopped"),
                    new MondaiWord("talking"),
                    new MondaiWord(";"),
                    new MondaiWord("otherwise"),
                }, shomon.MondaiWords);
            }
        }
        public void カード分割機能のデータ構造に対応させる()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = 何年前に君のおじさんはニューヨークにいたのですか。
                sei = a b/c/d e+f
                word = g
                word = h
            }
            shomon
            {
                id = shomon1
                mon = aaa
                sei = This+is a+ball.
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("a bcd e f", shomon.CorrectAnswers.First().Text);

                CollectionAssert.AreEquivalent(new []
                {
                    new MondaiWord("a"),
                    new MondaiWord("b", false, true),
                    new MondaiWord("c", true, true),
                    new MondaiWord("d", true, false),
                    new MondaiWord("e f"),
                    new MondaiWord("g"),
                    new MondaiWord("h"),

                }, shomon.MondaiWords);
            }
        }
        public void コメントアウトのテスト()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0

                mon = bbb /* aaa */

                sei = This is a ball.

            /*
                otr = apple (an apple)
            */
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("bbb", shomon.Mondaibun);
                CollectionAssert.AreEqual(new []
                {
                    new MondaiWord("This"),
                    new MondaiWord("is"),
                    new MondaiWord("a"),
                    new MondaiWord("ball"),
                    new MondaiWord("."),
                }, shomon.MondaiWords);
            }
        }
        public void seiが指定されなかったとき例外を送出する()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = aaa
                sei = This is a ball.
                sei =
                otori = apple (an apple)
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
            /*				var element = EmpDocument.Load(tempFile.Name);
                Assert.Throws<EmpException>(() =>
                {
                    var mondaiDocument = element.GetMondaiDocument();
                });*/

                var accessor = new EmpDocumentAccessor1_0();
                Assert.Throws<EmpException>(() =>
                {
                    accessor.Load(tempFile.Name);
                });
            }
        }
        public void seiに2個以上の空白が含まれていた場合の処理()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = aaa
                sei = This  is a ball.
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var shomonElement = element.Body.GetAllItems().First(x => "shomon" == x.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = mondaiDocument.GetAllItems().OfType<Shomon>().First(x => "shomon0" == x.Id);
                Assert.AreEqual("This is a ball.", shomon.CorrectAnswers.First().Text);
                CollectionAssert.AreEqual
                (
                    new []
                    {
                        new MondaiWord("This"),
                        new MondaiWord("is"),
                        new MondaiWord("a"),
                        new MondaiWord("ball"),
                        new MondaiWord("."),
                    },
                    shomon.MondaiWords
                );
            }
        }
        public void Ankimon_SplitTest()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true

            ankimon
            {
                id = ankimon0
                item
                {
                    name =
                    split = a b
                }
                item
                {
                    name =
                    split = c+d e
                }
            }
            shomon
            {
                id = e7013152-ed57-4a6c-a2c0-c4b8dab26bd5
                mon = 何年前に君のおじさんはニューヨークにいたのですか。
                sei = How many years ago was your uncle in New+York?
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

                var ankimon = (Ankimon)mondaiDocument.GetItem("ankimon0");

                Assert.AreEqual(2, ankimon.AnkimonItems.Count());
                CollectionAssert.AreEqual(new [] { "a", "b", }, ankimon.AnkimonItems[0].MondaiWords.Select(x => x.Text));
                CollectionAssert.AreEqual(new [] { "c d", "e", }, ankimon.AnkimonItems[1].MondaiWords.Select(x => x.Text));

                var shomon = (Shomon)mondaiDocument.GetItem("e7013152-ed57-4a6c-a2c0-c4b8dab26bd5");
                Assert.AreEqual("New York", shomon.MondaiWords[shomon.MondaiWords.Count() - 2].Text);
                Assert.AreEqual("How many years ago was your uncle in New York?", shomon.CorrectAnswers[0].Text);
                Assert.AreEqual(10, shomon.MondaiWords.Count());
            }
        }
        public void optionalにtruefalse以外が指定されていたら例外()
        {
            var text =
            @"
            document
            {
            id = document1
            title = documentB

            daimon
            {
            id = id1
            title = ""daimonTitle""

            chumon
            {
            id = chumon2-2
            title = ""chumonTitle""

            shuffle = aaa

            shomon
            {
                id = shomon3
                mon
                {
                    Are these cameras?
                }

                sei
                {
                    No, they aren't.
                }

                word
                {
                    Yes,
                }
                word
                {
                    they are.
                }
            }
            }
            }
            }
            ";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                Assert.Throws<EmpException>(() =>
                {
                    accessor.Load(tempFile.Name);
                });

            /*				var emp = EmpDocument.Load(tempFile.Name);
                Assert.Throws<EmpException>(() =>
                {
                    emp.GetMondaiDocument();
                });*/
            }
        }
        public void LettersThatAreDisplayedOnCardに対応させる()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                display = all
                mon = bbb
                sei = They need two kind of support: economic and technical.
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("bbb", shomon.Mondaibun);
                Assert.AreEqual(LettersThatAreDisplayedOnCard.All, shomon.LettersThatAreDisplayedOnCard);
            }
        }
        public void helpIdに空文字を指定されたら無視する()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            ankimon
            {
                id = ankimon0
                item
                {
                    name =
                    split = a b
                }
                item
                {
                    name =
                    split = c+d e
                }
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);
                var chumon = mondaiDocument.GetItem("chumon0");
                Assert.IsEmpty(chumon.HelpIds);
            }
        }
        public void 括弧関連の不具合()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = bbb
                sei = This watch cost me (7,500 yen).
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("bbb", shomon.Mondaibun);
                CollectionAssert.AreEqual(new []
                {
                    new MondaiWord("This"),
                    new MondaiWord("watch"),
                    new MondaiWord("cost"),
                    new MondaiWord("me"),
                    new MondaiWord("7,500 yen"),
                    new MondaiWord("."),
                }, shomon.MondaiWords);
            }
        }
        public void 括弧とクォーテーションに対応させる()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = bbb
                sei = Not saying (""thank you"") is rude.
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = (Shomon)mondaiDocument.GetItem("shomon0");
                Assert.AreEqual("bbb", shomon.Mondaibun);
                CollectionAssert.AreEqual(new []
                {
                    new MondaiWord("Not"),
                    new MondaiWord("saying"),
                    new MondaiWord(@"""thank you"""),
                    new MondaiWord("is"),
                    new MondaiWord("rude"),
                    new MondaiWord("."),
                }, shomon.MondaiWords);
            }
        }
        public void 括弧でまとめて指定()
        {
            var text = @"
            document
            {
            id = document0
            title =

            daimon
            {
            id = daimon0
            title =

            chumon
            {
            id = chumon0
            title =
            shuffle = true
            helpId =
            helpId =

            shomon
            {
                id = shomon0
                mon = aaa
                sei = (This is) (a ball).
            }
            }
            }
            }";

            using (var tempFile = new TempFile(text))
            {
                var accessor = new EmpDocumentAccessor1_0();
                var mondaiDocument = accessor.Load(tempFile.Name);

            //				var element = EmpDocument.Load(tempFile.Name);
            //				var shomonElement = element.Body.GetAllItems().First(x => "shomon" == x.Name);
            //				Assert.AreEqual("(This is) (a ball).", shomonElement.GetValue("sei"));
            //				var mondaiDocument = element.GetMondaiDocument();

                var shomon = mondaiDocument.GetAllItems().OfType<Shomon>().First(x => "shomon0" == x.Id);

                CollectionAssert.AreEqual
                (
                    new []
                    {
                        new MondaiWord("This is"),
                        new MondaiWord("a ball"),
                        new MondaiWord("."),
                    },
                    shomon.MondaiWords
                );
            }
        }