public void VersionTest()
 {
     var fileAccessor = new MondaiDocumentFileAccessor1_1();
     Assert.AreEqual("1.1", fileAccessor.Version);
 }
        public void LoadingAndSavingTest()
        {
            var xml =
            @"<?xml version=""1.0"" encoding=""utf-8""?>
            <mondaiDocument version=""1.1"" id=""mondaiDocument1"">
            <title>Mondai Document 1</title>
            <description>Mondai Document 1の説明</description>
            <daimon id=""daimon1"">
            <title>Daimon 1</title>
            <description>Daimon 1の説明</description>
            <chumon id=""chumon1"">
            <title>Chumon 1</title>
            <description>Chumon 1の説明</description>
            <optional />
            <shuffle />
            <helpId>help1</helpId>
            <shomon id=""shomon1"">
                <question>彼はその翌日そこに行くといいました。</question>
                <correctAnswer>He said that he would go there the next day.</correctAnswer>
                <correctAnswer>He said he would go there the next day.</correctAnswer>
                <description>英語は単語を空白で区切ります。</description>
                <inputMethod>card</inputMethod>
                <display>nothing</display>
                <soundFile when=""start"" numberOfTimes=""2"">sound1.wav</soundFile>
                <soundFile when=""start"" numberOfTimes=""2"">sound1.1.wav</soundFile>
                <soundFile when=""userRequest"" repeat=""true"">sound1.wav</soundFile>
                <soundFile when=""end"">sound2.wav</soundFile>
                <card>
                    <display>all</display>
                    <soundFile numberOfTimes=""2"">He said.wav</soundFile>
                    <text>He said</text>
                </card>
                <card>
                    <display>firstCharacterOnly</display>
                    <text>that</text>
                </card>
                <card>
                    <text>he would go there</text>
                </card>
                <card>
                    <rightJoint />
                    <text>i</text>
                </card>
                <card>
                    <rightJoint />
                    <leftJoint />
                    <text>ni</text>
                </card>
                <card>
                    <leftJoint />
                    <text>tial</text>
                </card>
                <card>
                    <text>the next day.</text>
                </card>
            </shomon>
            <shomon id=""shomon2"">
                <question>[英訳] これはボールです。</question>
                <correctAnswer>This is a ball.</correctAnswer>
                <description></description>
                <inputMethod>typing</inputMethod>
            </shomon>
            </chumon>
            <chumon id=""chumon2"">
            <title>I'm a policeman.</title>
            <description></description>
            <shomon id=""1-2-1"">
                <question>[英訳] これはボールです。</question>
                <correctAnswer>This is a ball.</correctAnswer>
                <description></description>
                <inputMethod>card</inputMethod>
                <card>
                    <text>This</text>
                </card>
                <card>
                    <text>is</text>
                </card>
                <card>
                    <text>a</text>
                </card>
                <card>
                    <text>ball</text>
                </card>
                <card>
                    <text>.</text>
                </card>
            </shomon>
            </chumon>
            </daimon>
            <daimon id=""daimon2"">
            <title>Daimon 2</title>
            <description></description>
            <chumon id=""chumon3"">
            <title>Mr. Brown is a doctor.</title>
            <description></description>
            <shuffle />
            <shomon id=""2-1-1"">
                <question>[英訳] これはボールです。</question>
                <correctAnswer>This is a ball.</correctAnswer>
                <description></description>
                <inputMethod>card</inputMethod>
                <card>
                    <text>This</text>
                </card>
                <card>
                    <text>is</text>
                </card>
                <card>
                    <text>a</text>
                </card>
                <card>
                    <text>ball</text>
                </card>
                <card>
                    <text>.</text>
                </card>
            </shomon>
            </chumon>
            </daimon>
            <daimon id=""daimon3"">
            <title>Daimon 3</title>
            <description></description>
            <chumon id=""chumon4"">
            <title>This is a pen.</title>
            <description></description>
            <shomon id=""3-1-1"">
                <question>[英訳] これはボールです。</question>
                <correctAnswer>This is a ball.</correctAnswer>
                <description></description>
                <inputMethod>card</inputMethod>
                <card>
                    <text>This</text>
                </card>
                <card>
                    <text>is</text>
                </card>
                <card>
                    <text>a</text>
                </card>
                <card>
                    <text>ball</text>
                </card>
                <card>
                    <text>.</text>
                </card>
            </shomon>
            </chumon>
            </daimon>
            </mondaiDocument>";

            using (var tempFile = new TempFile(xml))
            {
                var fileAccessor = new MondaiDocumentFileAccessor1_1();
                var mDoc = fileAccessor.Load(tempFile.Name);
                Assert.NotNull(mDoc);
                Assert.AreEqual("Mondai Document 1", mDoc.Name);
                Assert.AreEqual("Mondai Document 1の説明", mDoc.Description);
                {
                    var daimon = (Daimon)mDoc.GetItem("daimon1");
                    Assert.AreEqual("Daimon 1", daimon.Name);
                    Assert.AreEqual("Daimon 1の説明", daimon.Description);
                }
                {
                    var chumon = (Chumon)mDoc.GetItem("chumon1");
                    Assert.NotNull(chumon);
                    Assert.AreEqual("Chumon 1", chumon.Name);
                    Assert.AreEqual("Chumon 1の説明", chumon.Description);
                    Assert.True(chumon.IsShuffled);
                    Assert.True(chumon.IsOptional);

                    {
                        var shomon = (Shomon)chumon.GetItem("shomon1");
                        Assert.NotNull(shomon);
                        Assert.Null(shomon.Name);
                        Assert.AreEqual("英語は単語を空白で区切ります。", shomon.Description);
                        Assert.AreEqual(ShomonInputMethod.Card, shomon.InputMethod);
                        Assert.AreEqual(LettersThatAreDisplayedOnCard.Nothing, shomon.LettersThatAreDisplayedOnCard);

            /*
                        <soundFile when=""start"" numberOfTimes=""2"">sound1.wav</soundFile>
                        <soundFile when=""start"" numberOfTimes=""2"">sound1.1.wav</soundFile>
                        <soundFile when=""userRequest"" repeat=""true"">sound1.wav</soundFile>
                        <soundFile when=""end"">sound2.wav</soundFile>
            */

                        {
                            Assert.AreEqual(4, shomon.Sounds.Count());
                            int i = 0;
                            {
                                var sound = shomon.Sounds[i++];
                                Assert.AreEqual("sound1.wav", sound.FileName);
                                Assert.AreEqual(SoundIsPlayedWhen.Start, sound.IsPlayedWhen);
                                Assert.AreEqual(2, sound.NumberOfTimes);
                                Assert.False(sound.IsRepeated);
                            }
                            {
                                var sound = shomon.Sounds[i++];
                                Assert.AreEqual("sound1.1.wav", sound.FileName);
                                Assert.AreEqual(SoundIsPlayedWhen.Start, sound.IsPlayedWhen);
                                Assert.AreEqual(2, sound.NumberOfTimes);
                                Assert.False(sound.IsRepeated);
                            }
                            {
                                var sound = shomon.Sounds[i++];
                                Assert.AreEqual("sound1.wav", sound.FileName);
                                Assert.AreEqual(SoundIsPlayedWhen.UserRequest, sound.IsPlayedWhen);
                                Assert.AreEqual(1, sound.NumberOfTimes);
                                Assert.True(sound.IsRepeated);
                            }
                            {
                                var sound = shomon.Sounds[i++];
                                Assert.AreEqual("sound2.wav", sound.FileName);
                                Assert.AreEqual(SoundIsPlayedWhen.End, sound.IsPlayedWhen);
                                Assert.AreEqual(1, sound.NumberOfTimes);
                                Assert.False(sound.IsRepeated);
                            }
                        }
                        {
                            Assert.AreEqual(7, shomon.MondaiWords.Count());

            /*
                <card>
                    <display>all</display>
                    <soundFile numberOfTimes=""2"">He said.wav</soundFile>
                    <text>He said</text>
                </card>
            */

                            int i = 0;
                            {
                                var word = shomon.MondaiWords[i++];
                                Assert.AreEqual(LettersThatAreDisplayedOnCard.All, word.LettersThatAreDisplayedOnCard);
                                Assert.AreEqual("He said", word.Text);
                                Assert.False(word.HasLeftJoint);
                                Assert.False(word.HasRightJoint);
                                Assert.AreEqual(1, word.Sounds.Count());

                                int k = 0;
                                {
                                    var sound = word.Sounds[k++];
                                    Assert.AreEqual("He said.wav", sound.FileName);
                                    Assert.AreEqual(2, sound.NumberOfTimes);
                                    Assert.False(sound.IsRepeated);
                                    Assert.AreEqual(SoundIsPlayedWhen.Start, sound.IsPlayedWhen);
                                }
                            }
                            {
                                var word = shomon.MondaiWords[i++];
                                Assert.AreEqual(LettersThatAreDisplayedOnCard.FirstCharacterOnly, word.LettersThatAreDisplayedOnCard);
                                Assert.AreEqual("that", word.Text);
                                Assert.False(word.HasLeftJoint);
                                Assert.False(word.HasRightJoint);
                                Assert.AreEqual(0, word.Sounds.Count());
                            }
                            {
                                var word = shomon.MondaiWords[i++];
                                Assert.AreEqual(LettersThatAreDisplayedOnCard.Default, word.LettersThatAreDisplayedOnCard);
                                Assert.AreEqual("he would go there", word.Text);
                                Assert.False(word.HasLeftJoint);
                                Assert.False(word.HasRightJoint);
                                Assert.AreEqual(0, word.Sounds.Count());
                            }
                            {
                                var word = shomon.MondaiWords[i++];
                                Assert.AreEqual(LettersThatAreDisplayedOnCard.Default, word.LettersThatAreDisplayedOnCard);
                                Assert.AreEqual("i", word.Text);
                                Assert.False(word.HasLeftJoint);
                                Assert.True(word.HasRightJoint);
                                Assert.AreEqual(0, word.Sounds.Count());
                            }
                            {
                                var word = shomon.MondaiWords[i++];
                                Assert.AreEqual(LettersThatAreDisplayedOnCard.Default, word.LettersThatAreDisplayedOnCard);
                                Assert.AreEqual("ni", word.Text);
                                Assert.True(word.HasLeftJoint);
                                Assert.True(word.HasRightJoint);
                                Assert.AreEqual(0, word.Sounds.Count());
                            }
                            {
                                var word = shomon.MondaiWords[i++];
                                Assert.AreEqual(LettersThatAreDisplayedOnCard.Default, word.LettersThatAreDisplayedOnCard);
                                Assert.AreEqual("tial", word.Text);
                                Assert.True(word.HasLeftJoint);
                                Assert.False(word.HasRightJoint);
                                Assert.AreEqual(0, word.Sounds.Count());
                            }
                            {
                                var word = shomon.MondaiWords[i++];
                                Assert.AreEqual(LettersThatAreDisplayedOnCard.Default, word.LettersThatAreDisplayedOnCard);
                                Assert.AreEqual("the next day.", word.Text);
                                Assert.False(word.HasLeftJoint);
                                Assert.False(word.HasRightJoint);
                                Assert.AreEqual(0, word.Sounds.Count());
                            }
                            // LettersThatAreDisplayedOnCard.Defaultプロパティは上のオブジェクトの状態を継承する。
                        }
                    }
                }

                using (var savedFile = new TempFile())
                {
                    fileAccessor.Save(savedFile.Name, mDoc);
            //					TestUtility.CompareWithWinMerge(tempFile.Name, savedFile.Name);
                    FileAssert.AreEqual(tempFile.Name, savedFile.Name);
                }
            }
        }