public void DaimonButtonBoxでDaimon間を遷移()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var daimons = window.EPuzzleData.CurrentMondaiDocument.GetAllItems().OfType<Daimon>().ToArray();

                test.Unlock(daimons[0].Id);
                CollectionAssert.AreEqual(new [] { false, false, true, true, true, true, true }, daimons.Select(x => x.IsLocked(userInfo)));

                window.State = new DaimonState(window, daimons[0]);
                Assert.IsInstanceOf<DaimonState>(window.State);
                Assert.AreSame(daimons[0], ((DaimonState)window.State).Daimon);

                var daimonButtons = window.State.GetAllItems().OfType<DaimonButton>().ToArray();
                window.State.CurrentItem = daimonButtons[1];
                window.State.OnAction0();

                test.AddTime(10d);
                window.Tick();
                test.AddTime(10d);
                window.Tick();

                Assert.IsInstanceOf<DaimonState>(window.State);
                Assert.AreSame(daimons[1], ((DaimonState)window.State).Daimon);
            }
        }
        public void GetLastGradeTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var daimon = mondaiDocument.GetItem("daimon1");
                var t0 = new DateTime(2013, 1, 23, 0, 0, 0, DateTimeKind.Local);
                var t1 = new DateTime(2013, 1, 24, 0, 0, 0, DateTimeKind.Local);
                var t2 = new DateTime(2013, 1, 25, 0, 0, 0, DateTimeKind.Local);
                Chumon chumon = null;

                userInfo.GradeProcessor = GradeProcessorB.Instance;
                /*
                daimon.GradeProcessor = GradeProcessorB.Instance;
                foreach (var c in daimon.Items)
                {
                    c.GradeProcessor = GradeProcessorB.Instance;
                }
                */

                Assert.AreEqual(2, daimon.Items.Count());
                Assert.Null(daimon.GetLastGrade(userInfo));
                Assert.AreEqual("-", daimon.GetLastAndBestString(userInfo));

                chumon = (Chumon)daimon.GetItem("chumon1");
                Assert.Null(chumon.GetLastGrade(userInfo));
                Assert.AreEqual("-", chumon.GetLastAndBestString(userInfo));
                userInfo.MondaiResults.AddNew(chumon.Id, t0, chumon.GetTimeLimit(userInfo));
                Assert.AreEqual("A", chumon.GetLastAndBestString(userInfo));
                Assert.AreEqual(1d, chumon.GetLastGrade(userInfo));
                Assert.Null(daimon.GetLastGrade(userInfo));
                Assert.AreEqual("-", daimon.GetLastAndBestString(userInfo));

                chumon = (Chumon)daimon.GetItem("d1-chumon2");
                userInfo.MondaiResults.AddNew(chumon.Id, t0, chumon.GetTimeLimit(userInfo));
                Assert.AreEqual(1d, daimon.GetLastGrade(userInfo));
                Assert.AreEqual("A", daimon.GetLastAndBestString(userInfo));

                chumon = (Chumon)daimon.GetItem("chumon1");
                userInfo.MondaiResults.AddNew(chumon.Id, t1, chumon.GetTimeLimit(userInfo) + chumon.GetTimeLimit(userInfo));
                Assert.AreEqual("C:A", chumon.GetLastAndBestString(userInfo));
                Assert.AreEqual(2d, chumon.GetLastGrade(userInfo));
                Assert.AreEqual(2d, daimon.GetLastGrade(userInfo));
                Assert.AreEqual("C:A", daimon.GetLastAndBestString(userInfo));

                chumon = (Chumon)daimon.GetItem("chumon1");
                userInfo.MondaiResults.AddNew(chumon.Id, t2, chumon.GetTimeLimit(userInfo));
                Assert.AreEqual(1d, chumon.GetLastGrade(userInfo));
                Assert.AreEqual(1d, daimon.GetLastGrade(userInfo));
                Assert.AreEqual("A", chumon.GetLastAndBestString(userInfo));
                Assert.AreEqual("A", daimon.GetLastAndBestString(userInfo));
            }
        }
        public void Test1()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;

                Assert.Throws<ArgumentNullException>(() =>
                {
                    new StartGameState(window, null);
                });
            /*				Assert.Throws<ArgumentException>(() =>
                {
                    new StartGameState(window, new [] { "xxx", });
                });*/

                {
                    var startGameState = new StartGameState(window, new string[0]);
                    var tutorButton = startGameState.GetAllItems().Where(x => "tutorButton" == x.Name).FirstOrDefault();
                    Assert.Null(tutorButton);
                }

                window.State = new StartGameState(window, new [] { "mondaiDocument2", });

                {
                    var tutorButton = window.State.GetAllItems().Where(x => "tutorButton" == x.Name).FirstOrDefault();
                    Assert.NotNull(tutorButton);
                }

                var tsudukiKaraButton = window.State.GetAllItems().OfType<EigoTestButtonItem>().FirstOrDefault(x => "tsudukiKara" == x.Name);
                Assert.Null(tsudukiKaraButton);

                var daimon = (Daimon)mondaiDocument.GetItem("daimon2");
                userInfo.SetLastDaimonInfo(daimon);

                window.State = new StartGameState(window);
                tsudukiKaraButton = window.State.GetAllItems().OfType<EigoTestButtonItem>().FirstOrDefault(x => "tsudukiKara" == x.Name);
                Assert.NotNull(tsudukiKaraButton);

                window.State.CurrentItem = tsudukiKaraButton;
                window.State.OnAction0();

                test.AddTime(10d);
                window.Tick();
                test.AddTime(10d);
                window.Tick();

                Assert.IsInstanceOf<DaimonState>(window.State);
                Assert.AreSame(daimon, ((DaimonState)window.State).Daimon);
            }
        }
        public void LastText_BestText()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var chumon = (Chumon)mondaiDocument.GetItem("chumon1");
                var t0 = new DateTime(2013, 1, 18, 17, 3, 0, DateTimeKind.Local);
                var t1 = new DateTime(2013, 1, 18, 18, 19, 0, DateTimeKind.Local);
                var now = new DateTime(2013, 1, 19, 17, 0, 0, DateTimeKind.Local);
                test.Now = now;

                var kirokuInfoBox = new KirokuInfoBox()
                {
                    UserInfo = userInfo,
                    Chumon = chumon,
                };

                Assert.AreEqual("", kirokuInfoBox.LastText);
                Assert.AreEqual("", kirokuInfoBox.BestText);

                userInfo.MondaiResults.AddNew(chumon.Id, t0, chumon.GetTimeLimit(userInfo));
                userInfo.MondaiResults.AddNew(chumon.Id, t1, chumon.GetTimeLimit(userInfo) + TimeSpan.FromSeconds(1d));

                {
                    var text = string.Format(
            @"前回 (1日前)
            2013/01/18(金) 18:19
            00:{0:00} (B)", chumon.GetTimeLimit(userInfo).Seconds + 1d);

                    Assert.AreEqual(text, kirokuInfoBox.LastText);
                }

                {
                    var text = string.Format(
            @"最速 (1日前)
            2013/01/18(金) 17:03
            00:{0:00} (A)", chumon.GetTimeLimit(userInfo).Seconds);
                    Assert.AreEqual(text, kirokuInfoBox.BestText);

                }

                var chumon2 = (Chumon)mondaiDocument.GetItem("2-1");
                kirokuInfoBox.Chumon = chumon2;

                Assert.AreEqual("", kirokuInfoBox.LastText);
                Assert.AreEqual("", kirokuInfoBox.BestText);
            }
        }
        public void Action3で続けるボタン()
        {
            using (var testManager = new EPuzzleTestManager())
            {
                testManager.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                testManager.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                testManager.AddFile(@"help\help0.png", fileName => new Bitmap(100, 100).Save(fileName, System.Drawing.Imaging.ImageFormat.Png));
                testManager.Initialize();

                var window = testManager.Window;
                var helpDocumentSet = window.EPuzzleData.HelpDocumentSet;
                Assert.NotNull(helpDocumentSet);
                Assert.AreEqual("name0", helpDocumentSet.GetItem("help0").Name);

                var daimon = (Daimon)window.EPuzzleData.MondaiDocuments[0].GetItem("daimon1");
                var daimonState = new DaimonState(window, daimon);
                window.State = daimonState;
                var chumonButton = (ChumonButton)window.State.GetAllItems().OfType<ChumonButton>().First();
                var chumon = (Chumon)chumonButton.Chumon;
                Assert.AreEqual("chumon1", chumon.Id);

                window.State.CurrentItem = chumonButton;
                window.State.OnAction0();

                testManager.AddTime(10);
                window.Tick();
                testManager.AddTime(10);
                window.Tick();

                Assert.IsInstanceOf<HelpItemState>(window.State);

                // 続けるボタン
                var tsudukeru = window.State.GetAllItems().First(x => "tsudukeru" == x.Name);
                window.State.CurrentItem = tsudukeru;
                window.State.OnAction3();
                window.Tick();

                Assert.IsInstanceOf<ClickDeKaishiState>(window.State);
            }
        }
        public void Test1()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;

                var chumon = (Chumon)mondaiDocument.Items.First().Items.First();

                {
                    var chumonButton = new ChumonButton(userInfo, chumon);
                    Assert.AreSame(chumon, chumonButton.Chumon);
                    Assert.AreEqual(chumon.Id, chumonButton.Name);
                    Assert.False(chumonButton.HasGoldMedal);
                    Assert.False(chumonButton.HasSilverMedal);
                }

                userInfo.Medals.Add(new Medal(chumon.Id, Difficulty.Normal));
                {
                    var chumonButton = new ChumonButton(userInfo, chumon);
                    Assert.AreSame(chumon, chumonButton.Chumon);
                    Assert.AreEqual(chumon.Id, chumonButton.Name);
                    Assert.False(chumonButton.HasGoldMedal);
                    Assert.True(chumonButton.HasSilverMedal);
                }

                userInfo.Medals.Add(new Medal(chumon.Id, Difficulty.Hard));
                {
                    var chumonButton = new ChumonButton(userInfo, chumon);
                    Assert.AreSame(chumon, chumonButton.Chumon);
                    Assert.AreEqual(chumon.Id, chumonButton.Name);
                    Assert.True(chumonButton.HasGoldMedal);
                    Assert.True(chumonButton.HasSilverMedal);
                }
            }
        }
        public void DaimonButtonBox_DaimonIndexのテスト()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var daimons = window.EPuzzleData.CurrentMondaiDocument.GetAllItems().OfType<Daimon>().ToArray();
                foreach (var daimon in daimons)
                {
                    test.Unlock(daimon);
                }
                window.State = new DaimonState(window, daimons[0]);

                {
                    Assert.IsInstanceOf<DaimonState>(window.State);
                    Assert.AreEqual("daimon1", ((DaimonState)window.State).Daimon.Id);
                    var daimonButtonBox = window.State.GetAllItems().OfType<DaimonButtonBox>().First();
                    Assert.AreEqual(0, daimonButtonBox.DaimonIndex);
                }

                var nextButton = window.State.GetAllItems().OfType<NextButton>().First();
                window.State.CurrentItem = nextButton;
                window.State.OnAction0();

                test.AddTime(10d);
                window.Tick();
                test.AddTime(10d);
                window.Tick();

                {
                    Assert.IsInstanceOf<DaimonState>(window.State);
                    Assert.AreEqual("daimon2", ((DaimonState)window.State).Daimon.Id);
                    var daimonButtonBox = window.State.GetAllItems().OfType<DaimonButtonBox>().First();
                    Assert.AreEqual(1, daimonButtonBox.DaimonIndex);
                }
            }
        }
        public void GetGradeTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai02);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var chumon = (Chumon)mondaiDocument.GetItem("d1_chumon1");
                var now = new DateTime(2013, 2, 6, 10, 52, 10);

                Assert.Throws<ArgumentNullException>(() =>
                {
                    chumon.GetGrade(null, userInfo);
                });
                Assert.Throws<ArgumentException>(() =>
                {
                    chumon.GetGrade(new MondaiResult("xxx", now, chumon.GetTimeLimit(userInfo), window.EPuzzleData.CurrentUserInfo.Difficulty), userInfo);
                });
                Assert.AreEqual(1d, chumon.GetGrade(new MondaiResult(chumon.Id, now, chumon.GetTimeLimit(userInfo), window.EPuzzleData.CurrentUserInfo.Difficulty), userInfo));
            }
        }
        public void BackToStartGameStateButtonTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\Mondai3.xml", TestResources.Mondai03);
                test.AddFile(@"mondai\Mondai2.xml", TestResources.Mondai02);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondai2 = window.EPuzzleData.MondaiDocuments[0];
                var mondai3 = window.EPuzzleData.MondaiDocuments[1];

            //				CollectionAssert.AreEqual(new [] { "mondaiDocument1", }, EPuzzleTutor.GetMondaiDocumentsFromIds(window.EPuzzleData.MondaiDocuments, new [] { "mondaiDocument1", }).Select(x => x.Id));
                CollectionAssert.AreEqual(new [] { "mondaiDocument1", }, GetIds(TestUtility.Inv(typeof(EPuzzleTutor), "GetMondaiDocumentsFromIds", window.EPuzzleData.MondaiDocuments, new [] { "mondaiDocument1", })));

                var tutor = new EPuzzleTutor(userInfo, window.EPuzzleData.MondaiDocuments, TimeSpan.FromHours(12d), 30);
                var tutorState = new TutorState(window, tutor);

                window.State = tutorState;
                Assert.IsInstanceOf<TutorState>(window.State);

                var backToStartGameStateButton = tutorState.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "backToStartGameStateButton" == x.Name);
                window.State.CurrentItem = backToStartGameStateButton;
                window.State.OnAction0();

                Assert.IsInstanceOf<FadeoutState>(window.State);
                EPuzzleTime.Now += TimeSpan.FromSeconds(1d);
                window.Tick();
                Assert.IsInstanceOf<FadeinState>(window.State);
                EPuzzleTime.Now += TimeSpan.FromSeconds(1d);
                window.Tick();

                Assert.IsInstanceOf<StartGameState>(window.State);
            }
        }
        public void Add_lettersThatAreDisplayedOnCard_elementToShomon()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\Mondai4.xml", TestResources._mondai04);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondai = window.EPuzzleData.MondaiDocuments[0];
                var daimon = (Daimon)mondai.Items.First();
                var chumon = (Chumon)daimon.Items.First();
                var shomon = (Shomon)chumon.Items.First();

                Assert.AreEqual(LettersThatAreDisplayedOnCard.All, shomon.LettersThatAreDisplayedOnCard);
                shomon = (Shomon)shomon.NextItem;
                Assert.AreEqual(LettersThatAreDisplayedOnCard.Default, shomon.LettersThatAreDisplayedOnCard);

                using (var tempFile = new TempFile())
                {
                    mondai.Save(tempFile.Name, "1.0");
                    FileAssert.AreEqual(test.GetFullPath(@"mondai\Mondai4.xml"), tempFile.Name);
                }
            }
        }
        public void SortChumonsByDateYouDidThem_Test()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\mondai.xml", @"<?xml version=""1.0"" encoding=""utf-8""?>
            <mondai-document id=""doc1"" title=""DocumentB"">
            <daimon id=""d1"" title=""基礎I"">
            <chumon id=""c1"" title=""This is a pen."">
            <shomon id=""s1"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c2"" title=""This is a pen."">
            <shomon id=""s2"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c3"" title=""This is a pen."">
            <shomon id=""s3"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            </daimon>
            </mondai-document>");
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocuments = window.EPuzzleData.MondaiDocuments;
                var mondaiDocument = mondaiDocuments.First();

                userInfo.UseNewMethodThatGetsChumonsThatYouHaveDoneToday = true;
                userInfo.DoesNotShowChumonsYouHaveNeverDone = false;
                userInfo.TimeToChangeDay = new TimeSpan(3, 0, 0);
                userInfo.HideChumonsYouHaveGotGradeAToday = false;
                userInfo.Difficulty = Difficulty.Normal;

                // 期間における復習猶予期間の最大値を書き換える
                ((GradeProcessorB)userInfo.GradeProcessor).期間における復習猶予期間の最大値 = new []
                {
                    new Pair<TimeSpan, TimeSpan>(TimeSpan.FromHours(12d), TimeSpan.FromHours(12d)),
                };

                var tutor = new EPuzzleTutor(userInfo, mondaiDocuments, TimeSpan.FromHours(12d), 10);
                CollectionAssert.AreEqual(mondaiDocuments, tutor.MondaiDocuments);
                Assert.AreEqual(10, tutor.NumberOfQuestionsThatYouHaveToDoToday);
                Assert.AreEqual(TimeSpan.FromHours(12f), tutor.この時間以内の問題は無視する);

                var t0 = new DateTime(2014, 1, 21, 15, 0, 0, DateTimeKind.Local);
                var t1 = t0 + TimeSpan.FromMinutes(5d);
                var t2 = t1 + TimeSpan.FromMinutes(5d);
            //				var t3 = t2 + TimeSpan.FromMinutes(5d);
                EPuzzleTime.Now = t2 + TimeSpan.FromHours(3d);

                var mondaiResult = new MondaiResult("c1", t0, TimeSpan.FromSeconds(1d), Difficulty.Normal);
                userInfo.MondaiResults.Add(mondaiResult);

                CollectionAssert.AreEqual(new []
                {
                    "c1",
                }, GetIds(tutor.SortChumonsByDateYouDidThem()));

                userInfo.MondaiResults.AddNew("c2", t1, TimeSpan.FromSeconds(1d));

                CollectionAssert.AreEqual(new []
                {
                    "c2", "c1",
                }, GetIds(tutor.SortChumonsByDateYouDidThem()));

                userInfo.MondaiResults.AddNew("c1", t2, TimeSpan.FromSeconds(1d));

                CollectionAssert.AreEqual(new []
                {
                    "c1", "c2",
                }, GetIds(tutor.SortChumonsByDateYouDidThem()));

                // 難易度についてのテストは今回は行わない。難易度制度を残さない可能性があるため。
            }
        }
        public void ヘルプの表示は初回のみ()
        {
            using (var testManager = new EPuzzleTestManager())
            {
                testManager.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                testManager.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                testManager.AddFile(@"help\help0.png", fileName => new Bitmap(100, 100).Save(fileName, System.Drawing.Imaging.ImageFormat.Png));
                testManager.Initialize();

                var window = testManager.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var helpDocumentSet = window.EPuzzleData.HelpDocumentSet;
                Assert.NotNull(helpDocumentSet);
                Assert.AreEqual("name0", helpDocumentSet.GetItem("help0").Name);

                var daimon = (Daimon)window.EPuzzleData.MondaiDocuments[0].GetItem("daimon1");
                var daimonState = new DaimonState(window, daimon);
                window.State = daimonState;
                var chumonButton = (ChumonButton)window.State.GetAllItems().OfType<ChumonButton>().First();
                var chumon = (Chumon)chumonButton.Chumon;
                Assert.AreEqual("chumon1", chumon.Id);

                // クリア済み
                testManager.Unlock("chumon1");

                window.State.CurrentItem = chumonButton;
                window.State.OnAction0();

                testManager.AddTime(10);
                window.Tick();
                testManager.AddTime(10);
                window.Tick();

                Assert.IsInstanceOf<ClickDeKaishiState>(window.State);
                window.State.OnAction0();

                // 情報ボタンの押下でヘルプページに遷移する

                Assert.IsInstanceOf<ShomonState>(window.State);
                var shomonState = (ShomonState)window.State;
                Assert.AreEqual(2, shomonState.Shomon.Parent.HelpIds.Count());

                var infoButton = window.State.GetAllItems().First(x => "info" == x.Name);
                window.State.CurrentItem = infoButton;
                window.State.OnAction0();

                Assert.IsInstanceOf<HelpItemState>(window.State);
                var helpItems = (HelpItemBase[])TestUtility.GetValue(window.State, "_helpItems");
                Assert.AreEqual("help0", helpItems[0].Id);
            }
        }
        public void Test1()
        {
            using (var testManager = new EPuzzleTestManager())
            {
                testManager.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                testManager.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                testManager.AddFile(@"help\help0.png", fileName => new Bitmap(100, 100).Save(fileName, System.Drawing.Imaging.ImageFormat.Png));
                testManager.Initialize();

                var window = testManager.Window;
                var parentState = new WindowState(window);
                var helpItems = window.EPuzzleData.HelpDocumentSet.GetItems(new [] { "help0", "help1", "help2" });
                var helpItemState = new HelpItemState
                (
                    window: window,
                    helpItems: helpItems,
                    helpItemIndex: 0,
                    parentState: parentState
                );

                window.State = helpItemState;

                // index: 0
                {
                    var s  = window.State;
                    Assert.IsInstanceOf<HelpItemState>(s);
                    var helpItemButtons = s.GetAllItems().Where(x => x.Tag is HelpItem).ToArray();
                    CollectionAssert.IsSubsetOf(helpItems, helpItemButtons.Select(x => x.Tag));
                    CollectionAssert.AreEqual(new [] { false, true, true, }, helpItemButtons.Select(x => x.IsClickable));

                    var modoruButton = s.GetAllItems().First(x => "続ける" == x.Text);
                    var previousButton = s.GetAllItems().OfType<PreviousButton>().FirstOrDefault();
                    var nextButton = s.GetAllItems().OfType<NextButton>().FirstOrDefault();

                    Assert.Null(previousButton);
                    Assert.NotNull(nextButton);

                    window.State.CurrentItem = nextButton;
                    window.State.OnAction0();
                }
                // index: 1
                {
                    var s  = window.State;
                    Assert.IsInstanceOf<HelpItemState>(s);
                    var helpItemButtons = s.GetAllItems().Where(x => x.Tag is HelpItem).ToArray();
                    CollectionAssert.IsSubsetOf(helpItems, helpItemButtons.Select(x => x.Tag));
                    CollectionAssert.AreEqual(new [] { true, false, true, }, helpItemButtons.Select(x => x.IsClickable));

                    var modoruButton = s.GetAllItems().First(x => "続ける" == x.Text);
                    var previousButton = s.GetAllItems().FirstOrDefault(x => x is PreviousButton);
                    var nextButton = s.GetAllItems().FirstOrDefault(x => x is NextButton);

                    Assert.NotNull(previousButton);
                    Assert.NotNull(nextButton);

                    window.State.CurrentItem = nextButton;
                    window.State.OnAction0();
                }
                // index: 2
                {
                    var s  = window.State;
                    Assert.IsInstanceOf<HelpItemState>(s);
                    var helpItemButtons = s.GetAllItems().Where(x => x.Tag is HelpItem).ToArray();
                    CollectionAssert.IsSubsetOf(helpItems, helpItemButtons.Select(x => x.Tag));
                    CollectionAssert.AreEqual(new [] { true, true, false, }, helpItemButtons.Select(x => x.IsClickable));

                    var modoruButton = s.GetAllItems().First(x => "続ける" == x.Text);
                    var previousButton = s.GetAllItems().FirstOrDefault(x => x is PreviousButton);
                    var nextButton = s.GetAllItems().FirstOrDefault(x => x is NextButton);

                    Assert.NotNull(previousButton);
                    Assert.Null(nextButton);

                    window.State.CurrentItem = previousButton;
                    window.State.OnAction0();
                }
                // index: 1
                {
                    var s  = window.State;
                    Assert.IsInstanceOf<HelpItemState>(s);
                    var helpItemButtons = s.GetAllItems().Where(x => x.Tag is HelpItem).ToArray();
                    CollectionAssert.IsSubsetOf(helpItems, helpItemButtons.Select(x => x.Tag));
                    CollectionAssert.AreEqual(new [] { true, false, true, }, helpItemButtons.Select(x => x.IsClickable));

                    var modoruButton = s.GetAllItems().First(x => "続ける" == x.Text);
                    var previousButton = s.GetAllItems().FirstOrDefault(x => x is PreviousButton);
                    var nextButton = s.GetAllItems().FirstOrDefault(x => x is NextButton);

                    Assert.NotNull(previousButton);
                    Assert.NotNull(nextButton);

                    window.State.CurrentItem = previousButton;
                    window.State.OnAction0();
                }
                // index: 0
                {
                    var s  = window.State;
                    Assert.IsInstanceOf<HelpItemState>(s);
                    var helpItemButtons = s.GetAllItems().Where(x => x.Tag is HelpItem).ToArray();
                    CollectionAssert.IsSubsetOf(helpItems, helpItemButtons.Select(x => x.Tag));
                    CollectionAssert.AreEqual(new [] { false, true, true, }, helpItemButtons.Select(x => x.IsClickable));

                    var modoruButton = s.GetAllItems().First(x => "続ける" == x.Text);
                    var previousButton = s.GetAllItems().FirstOrDefault(x => x is PreviousButton);
                    var nextButton = s.GetAllItems().FirstOrDefault(x => x is NextButton);

                    Assert.Null(previousButton);
                    Assert.NotNull(nextButton);

                    window.State.CurrentItem = helpItemButtons[1];
                    window.State.OnAction0();
                }
                // index: 1
                {
                    var s  = window.State;
                    Assert.IsInstanceOf<HelpItemState>(s);
                    var helpItemButtons = s.GetAllItems().Where(x => x.Tag is HelpItem).ToArray();
                    CollectionAssert.IsSubsetOf(helpItems, helpItemButtons.Select(x => x.Tag));
                    CollectionAssert.AreEqual(new [] { true, false, true, }, helpItemButtons.Select(x => x.IsClickable));

                    var modoruButton = s.GetAllItems().First(x => "続ける" == x.Text);
                    Assert.NotNull(modoruButton);
                    var previousButton = s.GetAllItems().FirstOrDefault(x => x is PreviousButton);
                    var nextButton = s.GetAllItems().FirstOrDefault(x => x is NextButton);

                    Assert.NotNull(previousButton);
                    Assert.NotNull(nextButton);

                    window.State.CurrentItem = modoruButton;

                    // modoruButtonを左クリック
                    window.MouseUp(modoruButton.BorderLeft, modoruButton.BorderTop, MouseButtons.Left);
                }
                Assert.AreSame(parentState, window.State);
            }
        }
        public void MondaiDocumentのNextItem_PreviousItemを実装する()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\Mondai3.xml", TestResources.Mondai03);
                test.AddFile(@"mondai\Mondai2.xml", TestResources.Mondai02);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondai2 = window.EPuzzleData.MondaiDocuments[0];
                var mondai3 = window.EPuzzleData.MondaiDocuments[1];

                Assert.AreSame(mondai2, window.EPuzzleData.CurrentMondaiDocument);

                Assert.Null(mondai2.PreviousItem);
                Assert.AreSame(mondai3, mondai2.NextItem);

                Assert.AreSame(mondai2, mondai3.PreviousItem);
                Assert.Null(mondai3.NextItem);
            }
        }
        public void 要復習項目が正しく抽出されていない感じがする_266()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\mondai1.xml", _mondai1);
                test.AddFile(@"mondai\mondai2.xml", _mondai2);
                test.AddFile(@"mondai\mondai3.xml", _mondai3);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocuments = window.EPuzzleData.MondaiDocuments;

                // 期間における復習猶予期間の最大値を書き換える
                ((GradeProcessorB)userInfo.GradeProcessor).期間における復習猶予期間の最大値 = new []
                {
                    new Pair<TimeSpan, TimeSpan>(TimeSpan.FromHours(12d), TimeSpan.FromHours(12d)),
                };

                {
                    var tutor = new EPuzzleTutor(userInfo, mondaiDocuments, TimeSpan.FromHours(12d), 30);
                    CollectionAssert.AreEqual(mondaiDocuments, tutor.MondaiDocuments);

                    {
                        CollectionAssert.AreEqual(new []
                        {
                            "d11", "d21", "d31",
            //						}, tutor.GetAllDaimons().Select(x => x.Id));
                        }, TestUtility.Invoke<IEnumerable<Daimon>>(tutor, "GetAllDaimons").Select(x => x.Id));

                        CollectionAssert.AreEqual(new []
                        {
                            "d11", "d21", "d31",
            //						}, tutor.GetUnlockedDaimons().Select(x => x.Id));
                        }, TestUtility.Invoke<IEnumerable<Daimon>>(tutor, "GetUnlockedDaimons").Select(x => x.Id));

                        CollectionAssert.AreEqual(new []
                        {
                            "c11", "c21", "c31",
            //						}, GetIds(tutor.GetUnlockedChumons()));
                        }, GetIds(TestUtility.Inv(tutor, "GetUnlockedChumons")));

                        CollectionAssert.AreEqual(new []
                        {
                            "c11", "c21", "c31",
                        }, GetIds(TestUtility.Inv(tutor, "GetChumons")));
                    }

                    var t0 = new DateTime(2013, 6, 11, 0, 0, 0); // UTC
                    var t1 = t0 + TimeSpan.FromHours(1d);
                    var t2 = t1 + TimeSpan.FromHours(1d);

                    EPuzzleTime.Now = t2;
            //					tutor.NumberOfQuestionsThatYouHaveToDoToday = 3;
                    TestUtility.SetValue(tutor, "NumberOfQuestionsThatYouHaveToDoToday", 3);

                    CollectionAssert.AreEqual(new []
                    {
                        "c11", "c21", "c31",
                    }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                    // 指定時間が経過していないがグレードAに達していない問題はやっていないことにされるため。
                    userInfo.MondaiResults.AddNew("c11", t0, TimeSpan.FromMinutes(5d));

                    CollectionAssert.AreEqual(new []
                    {
                        "c21", "c31",
                    }, GetIds(TestUtility.Inv(tutor, "GetChumons")));
                }
            }
        }
        public void EPuzzleUserInfo_UseNewMethodThatGetsChumonsThatYouHaveDoneTodayへの対応テスト()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\mondai.xml", _mondai4);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocuments = window.EPuzzleData.MondaiDocuments;

                userInfo.UseNewMethodThatGetsChumonsThatYouHaveDoneToday = true;
                userInfo.TimeToChangeDay = new TimeSpan(3, 0, 0);

                // 期間における復習猶予期間の最大値を書き換える
                ((GradeProcessorB)userInfo.GradeProcessor).期間における復習猶予期間の最大値 = new []
                {
                    new Pair<TimeSpan, TimeSpan>(TimeSpan.FromHours(12d), TimeSpan.FromHours(12d)),
                };

                var tutor = new EPuzzleTutor(userInfo, mondaiDocuments, TimeSpan.FromHours(12d), 10);
                CollectionAssert.AreEqual(mondaiDocuments, tutor.MondaiDocuments);
                Assert.AreEqual(10, tutor.NumberOfQuestionsThatYouHaveToDoToday);
                Assert.AreEqual(TimeSpan.FromHours(12f), tutor.この時間以内の問題は無視する);

                var now = new DateTime(2014, 1, 21, 2, 0, 0, DateTimeKind.Local);

                // 表示される問題
                userInfo.MondaiResults.AddNew("c1", new DateTime(2014, 1, 10, 13, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(30d));
                userInfo.MondaiResults.AddNew("c1", new DateTime(2014, 1, 12, 14, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(30d));
                userInfo.MondaiResults.AddNew("c1", new DateTime(2014, 1, 20,  3, 1, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));

                userInfo.MondaiResults.AddNew("c2", new DateTime(2014, 1, 1,  1, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));
                userInfo.MondaiResults.AddNew("c2", new DateTime(2014, 1, 21,  1, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(30d));

                userInfo.MondaiResults.AddNew("c3", new DateTime(2014, 1, 1,  13, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));
                userInfo.MondaiResults.AddNew("c3", new DateTime(2014, 1, 6,  13, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));

                userInfo.MondaiResults.AddNew("c4", new DateTime(2014, 1, 10,  12, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));
                userInfo.MondaiResults.AddNew("c4", new DateTime(2014, 1, 19,  12, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));

                userInfo.MondaiResults.AddNew("c6", new DateTime(2013, 1, 10,  12, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(4d));
                userInfo.MondaiResults.AddNew("c6", new DateTime(2014, 1, 10,  12, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(4d));

                userInfo.MondaiResults.AddNew("c5", new DateTime(2014, 1, 10,  12, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));
                userInfo.MondaiResults.AddNew("c5", new DateTime(2014, 1, 20,  12, 0, 0, DateTimeKind.Local), TimeSpan.FromSeconds(2.9d));

                // 表示されない問題
                // "c8"

                EPuzzleTime.Now = now;

                CollectionAssert.AreEquivalent(new []
                {
                    "c1", "c2", "c3", "c4", "c5", "c6", "c7",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));
            }
        }
        public void 分表示がおかしい不具合()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var chumon = (Chumon)mondaiDocument.GetItem("chumon1");
                var t0 = new DateTime(2013, 1, 18, 17, 3, 0, DateTimeKind.Local);
                var t1 = new DateTime(2013, 1, 18, 18, 19, 0, DateTimeKind.Local);
                var now = new DateTime(2013, 1, 19, 17, 0, 0, DateTimeKind.Local);
                test.Now = now;

                {
                    var mondaiResult = new MondaiResult(chumon.Id, t0, TimeSpan.FromSeconds(70d), userInfo.Difficulty);
                    Assert.AreEqual(
            @"(1日前)
            2013/01/18(金) 17:04
            01:10 (F)", KirokuInfoBox.GetString(mondaiResult, chumon, userInfo));

                }
                {
                    var mondaiResult = new MondaiResult(chumon.Id, t0, TimeSpan.FromSeconds(110d), userInfo.Difficulty);
                    Assert.AreEqual(
            @"(1日前)
            2013/01/18(金) 17:04
            01:50 (F)", KirokuInfoBox.GetString(mondaiResult, chumon, userInfo));

                }
                {
                    var mondaiResult = new MondaiResult(chumon.Id, t0, TimeSpan.FromMinutes(100d), userInfo.Difficulty);
                    Assert.AreEqual(
            @"(1日前)
            2013/01/18(金) 18:43
            100:00 (F)", KirokuInfoBox.GetString(mondaiResult, chumon, userInfo));

                }
            }
        }
        public void IgnoreDifficultyTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;

                userInfo.IgnoreDifficultyWhenGettingMondaiResults = false;
                Assert.False(userInfo.IgnoreDifficultyWhenGettingMondaiResults);

                var t0 = new DateTime(2013, 11, 29, 0, 0, 0); // UTC
                var now = t0 + TimeSpan.FromMinutes(1d);
                EPuzzleTime.Now = now;

                var id = "id0";
                var mondaiResult1 = new MondaiResult(id, t0, TimeSpan.FromSeconds(10d), Difficulty.Hard);
                var mondaiResult2 = new MondaiResult(id, now, TimeSpan.FromSeconds(10d), Difficulty.Normal);

                userInfo.MondaiResults.Add(mondaiResult1);
                userInfo.MondaiResults.Add(mondaiResult2);

                userInfo.Difficulty = Difficulty.Normal;
                userInfo.IgnoreDifficultyWhenGettingMondaiResults = false;

                CollectionAssert.AreEqual(new []
                {
                    mondaiResult2,
                }, userInfo.MondaiResults.GetItems(id));
                CollectionAssert.AreEqual(new []
                {
                    mondaiResult2,
            //				}, userInfo.MondaiResults.GetItemsThatHaveBeenDoneWithin(TimeSpan.FromDays(1d)));
                }, (IEnumerable<MondaiResult>)TestUtility.Invoke(userInfo, "GetMondaiResultsThatYouHaveDoneWithin", TimeSpan.FromDays(1d)));

                userInfo.IgnoreDifficultyWhenGettingMondaiResults = true;

                CollectionAssert.AreEqual(new []
                {
                    mondaiResult1, mondaiResult2,
                }, userInfo.MondaiResults.GetItems(id));
                CollectionAssert.AreEqual(new []
                {
                    mondaiResult1, mondaiResult2,
            //				}, userInfo.MondaiResults.GetItemsThatHaveBeenDoneWithin(TimeSpan.FromDays(1d)));
                }, (IEnumerable<MondaiResult>)TestUtility.Invoke(userInfo, "GetMondaiResultsThatYouHaveDoneWithin", TimeSpan.FromDays(1d)));
            }
        }
        public void Test0()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\Mondai3.xml", TestResources.Mondai03);
                test.AddFile(@"mondai\Mondai2.xml", TestResources.Mondai02);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocuments = window.EPuzzleData.MondaiDocuments;
            //				userInfo.HoursToIgnoreMondaisThatYouHaveDone = 5.8f;

                // 期間における復習猶予期間の最大値を書き換える
                ((GradeProcessorB)userInfo.GradeProcessor).期間における復習猶予期間の最大値 = new []
                {
                    new Pair<TimeSpan, TimeSpan>(TimeSpan.FromHours(12d), TimeSpan.FromHours(12d)),
                };
                {
                    var tutor = new EPuzzleTutor(userInfo, new [] { mondaiDocuments[0], }, TimeSpan.FromHours(12d), 30);
                    CollectionAssert.AreEqual(new [] { mondaiDocuments[0], }, tutor.MondaiDocuments);
            //					Assert.AreEqual(TimeSpan.FromHours(5.8f), tutor.この時間以内の問題は無視する);
                }
            //				userInfo.HoursToIgnoreMondaisThatYouHaveDone = 6f;
                {
                    var tutor = new EPuzzleTutor(userInfo, mondaiDocuments, TimeSpan.FromHours(12d), 30);
                    CollectionAssert.AreEqual(mondaiDocuments, tutor.MondaiDocuments);
            //					Assert.AreEqual(TimeSpan.FromHours(6f), tutor.この時間以内の問題は無視する);

                    {
                        CollectionAssert.AreEqual(new []
                        {
                            "daimon1", "daimon2", "daimon3", "daimon1", "daimon2", "daimon3", "daimon4", "daimon5", "daimon6", "daimon_hatsuon_mondai_test",
            //						}, tutor.GetAllDaimons().Select(x => x.Id));
                        }, TestUtility.Invoke<IEnumerable<Daimon>>(tutor, "GetAllDaimons").Select(x => x.Id));

                        CollectionAssert.AreEqual(new []
                        {
                            "daimon1", "daimon1",
            //						}, tutor.GetUnlockedDaimons().Select(x => x.Id));
                        }, TestUtility.Invoke<IEnumerable<Daimon>>(tutor, "GetUnlockedDaimons").Select(x => x.Id));

                        CollectionAssert.AreEqual(new []
                        {
                            "d1_chumon1", "chumon1",
            //						}, GetIds(tutor.GetUnlockedChumons()));
                        }, GetIds(TestUtility.Inv(tutor, "GetUnlockedChumons")));

                        CollectionAssert.AreEqual(new []
                        {
                            "d1_chumon1", "chumon1",
                        }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                        var t0 = new DateTime(2013, 6, 11, 0, 0, 0); // UTC
                        var t1 = t0 + TimeSpan.FromDays(10d);
                        var t2 = t1 + TimeSpan.FromDays(10d);
                        var t2a = t2 + TimeSpan.FromDays(5d);
                        var t2b = t2a + TimeSpan.FromDays(1d);
                        var t3 = t2 + TimeSpan.FromDays(10d);

                        userInfo.MondaiResults.AddNew("d1_chumon1", t1, TimeSpan.FromSeconds(10d));
                        userInfo.MondaiResults.AddNew("d1_chumon2", t2, TimeSpan.FromSeconds(20d));
                        userInfo.MondaiResults.AddNew("d2_chumon1", t2a, TimeSpan.FromSeconds(1d));
                        userInfo.MondaiResults.AddNew("d2_chumon1", t2b, TimeSpan.FromSeconds(1d));
                        EPuzzleTime.Now = t3;

                        Assert.NotNull(mondaiDocuments[0].GetItem("d2_chumon2"));
                        Assert.NotNull(mondaiDocuments[1].GetItem("chumon1"));
                        Assert.AreEqual(t1 + TimeSpan.FromHours(12d), TestUtility.Inv(tutor, "復習猶予期間と最終プレイ時間を足す", (Chumon)mondaiDocuments[0].GetItem("d1_chumon1")));
                        Assert.AreEqual(t2 + TimeSpan.FromHours(12d), TestUtility.Inv(tutor, "復習猶予期間と最終プレイ時間を足す", (Chumon)mondaiDocuments[0].GetItem("d1_chumon2")));
                        Assert.AreEqual(t3, TestUtility.Inv(tutor, "復習猶予期間と最終プレイ時間を足す", (Chumon)mondaiDocuments[0].GetItem("d2_chumon2")));
                        Assert.AreEqual(t3, TestUtility.Inv(tutor, "復習猶予期間と最終プレイ時間を足す", (Chumon)mondaiDocuments[1].GetItem("chumon1")));
                        Assert.AreEqual
                        (
                            t2b + ((Chumon)mondaiDocuments[0].GetItem("d2_chumon1")).復習までの猶予期間を取得(userInfo),
                            TestUtility.Inv(tutor, "復習猶予期間と最終プレイ時間を足す", (Chumon)mondaiDocuments[0].GetItem("d2_chumon1"))
                        );

                        var d1_chumon1 = (Chumon)mondaiDocuments[0].GetItem("d1_chumon1");
                        var d1_chumon2 = (Chumon)mondaiDocuments[0].GetItem("d1_chumon2");
                        var d2_chumon1 = (Chumon)mondaiDocuments[0].GetItem("d2_chumon1");

                        Assert.False(d1_chumon1.IsLocked(userInfo));
                        Assert.False(d1_chumon2.IsLocked(userInfo));
                        Assert.False(d2_chumon1.IsLocked(userInfo));

                        CollectionAssert.AreEqual(new []
                        {
                            "d1_chumon1", "d1_chumon2", "d2_chumon2", "d2_chumon3", "d2_chumon4", "chumon1", "d2_chumon1"
                        }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                        CollectionAssert.AreEqual(new []
                        {
                            "A", "B", "-", "-", "-", "-", "A",
                        }, TestUtility.Invoke<IEnumerable<Chumon>>(tutor, "GetChumons").Select(x => x.GetGradeString(userInfo)).ToArray());

                        CollectionAssert.AreEqual(new []
                        {
                            "B", "A", "A", "-", "-", "-", "-",
                        }, tutor.GetChumons(true).Select(x => x.GetGradeString(userInfo)).ToArray());

                        userInfo.MondaiResults.AddNew("d1_chumon1", t3, TimeSpan.FromSeconds(1d));

                        CollectionAssert.AreEqual(new []
                        {
                            "d1_chumon2", "d2_chumon2", "d2_chumon3", "d2_chumon4", "chumon1", "d2_chumon1"
                        }, GetIds(TestUtility.Inv(tutor, "GetChumons")));
                    }
                }
            }
        }
        public void GetPlayTimeTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var t0 = new DateTime(2013, 11, 29, 0, 0, 0); // UTC
                var now = t0 + TimeSpan.FromMinutes(1d);
                EPuzzleTime.Now = now;

                userInfo.IgnoreDifficultyWhenGettingMondaiResults = false;
                userInfo.Difficulty = Difficulty.Normal;

                var id = "id0";
                userInfo.MondaiResults.Add(new MondaiResult(id, t0, TimeSpan.FromSeconds(9d), Difficulty.Hard));
                userInfo.MondaiResults.Add(new MondaiResult(id, now, TimeSpan.FromSeconds(10d), Difficulty.Normal));

                Assert.AreEqual(TimeSpan.FromSeconds(10d), userInfo.GetPlayTime());

                userInfo.IgnoreDifficultyWhenGettingMondaiResults = true;
                Assert.AreEqual(TimeSpan.FromSeconds(19d), userInfo.GetPlayTime());

                userInfo.IgnoreDifficultyWhenGettingMondaiResults = false;
                Assert.AreEqual(TimeSpan.FromSeconds(19d), userInfo.GetPlayTimeIgnoringDifficulty());
            }
        }
        public void GetPlayTimeOfTodayTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var t0 = new DateTime(2013, 11, 29, 0, 0, 0); // UTC
                var t1 = t0 + TimeSpan.FromDays(1d);
                var t2 = t1 + TimeSpan.FromMinutes(1d);
                var t3 = t2 + TimeSpan.FromMinutes(1d);
                var now = t3 + TimeSpan.FromMinutes(1d);
                EPuzzleTime.Now = now;

                userInfo.IgnoreDifficultyWhenGettingMondaiResults = false;
                userInfo.TimeToChangeDay = new TimeSpan(3, 0, 0);
                userInfo.UseNewMethodThatGetsChumonsThatYouHaveDoneToday = true;
                userInfo.Difficulty = Difficulty.Normal;

                var id = "id0";
                userInfo.MondaiResults.Add(new MondaiResult(id, t0, TimeSpan.FromSeconds(9d), Difficulty.Normal));
                userInfo.MondaiResults.Add(new MondaiResult(id, t1, TimeSpan.FromSeconds(11d), Difficulty.Normal));
                userInfo.MondaiResults.Add(new MondaiResult(id, t2, TimeSpan.FromSeconds(12d), Difficulty.Normal));
                userInfo.MondaiResults.Add(new MondaiResult(id, t3, TimeSpan.FromSeconds(13d), Difficulty.Hard));

                Assert.AreEqual(TimeSpan.FromSeconds(23d), userInfo.GetPlayTimeOfToday());

                userInfo.IgnoreDifficultyWhenGettingMondaiResults = true;
                Assert.AreEqual(TimeSpan.FromSeconds(36d), userInfo.GetPlayTimeOfToday());
            }
        }
        public void GetLastMondaiResultTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai02);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var chumon = (Chumon)mondaiDocument.GetItem("d1_chumon1");
                var t0 = new DateTime(2012, 12, 6, 0, 0, 0, DateTimeKind.Local);
                var t1 = new DateTime(2012, 12, 7, 0, 0, 0, DateTimeKind.Local);

                CollectionAssert.IsEmpty(userInfo.MondaiResults.GetOrderedItems(chumon.Id));
            //				Assert.Null(userInfo.MondaiResults.GetLast(chumon.Id));
                Assert.Null(userInfo.MondaiResults.GetNewest(chumon.Id));
                Assert.Null(userInfo.MondaiResults.GetBest(chumon.Id));

                var mondaiResult0 = new MondaiResult(chumon.Id, t0, chumon.GetTimeLimit(userInfo), userInfo.Difficulty);
                userInfo.MondaiResults.Add(mondaiResult0);

                var mondaiResult1 = new MondaiResult(chumon.Id, t1, chumon.GetTimeLimit(userInfo) + TimeSpan.FromSeconds(1d), userInfo.Difficulty);
                userInfo.MondaiResults.Add(mondaiResult1);

            //				chumon.GradeProcessor = GradeProcessorB.Instance;
                userInfo.GradeProcessor = GradeProcessorB.Instance;
            //				Assert.AreSame(mondaiResult1, userInfo.MondaiResults.GetLast(chumon.Id));
                Assert.AreSame(mondaiResult1, userInfo.MondaiResults.GetNewest(chumon.Id));
                Assert.AreSame(mondaiResult0, userInfo.MondaiResults.GetBest(chumon.Id));
                Assert.AreSame(mondaiResult0, userInfo.MondaiResults.GetOldest(chumon.Id));
                Assert.AreSame(mondaiResult1, userInfo.MondaiResults.GetNewest(chumon.Id));

                var items = userInfo.MondaiResults.GetOrderedItems(chumon.Id);
                CollectionAssert.AreEqual(new []
                {
                    mondaiResult1,
                    mondaiResult0,
                }, items);
            }
        }
        public void GetChumonsThatYouHaveDoneTodayTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;
                var t0 = new DateTime(2010, 1, 1, 2, 59, 0, DateTimeKind.Local);
                var t1 = new DateTime(2010, 1, 2, 2, 59, 0, DateTimeKind.Local);
                var t2 = new DateTime(2010, 1, 2, 2, 58, 0, DateTimeKind.Local);
                var t3 = new DateTime(2010, 1, 3, 3, 5, 0, DateTimeKind.Local);
                var t4 = t3 + TimeSpan.FromHours(1d);
                EPuzzleTime.Now = t4;

                userInfo.TimeToChangeDay = new TimeSpan(3, 0, 0);
                userInfo.UseNewMethodThatGetsChumonsThatYouHaveDoneToday = true;
                userInfo.Difficulty = Difficulty.Normal;

                userInfo.MondaiResults.AddNew("chumon1", t0, TimeSpan.FromSeconds(1d));
                userInfo.MondaiResults.AddNew("chumon1", t1, TimeSpan.FromSeconds(1d));
                userInfo.MondaiResults.AddNew("d1-chumon2", t2, TimeSpan.FromSeconds(1d));
                userInfo.MondaiResults.AddNew("chumon1", t3, TimeSpan.FromSeconds(1d));

                CollectionAssert.AreEqual(new [] { "chumon1", }, userInfo.GetMondaiResultsThatYouHaveDoneToday().Select(x => x.MondaiId));

                userInfo.UseNewMethodThatGetsChumonsThatYouHaveDoneToday = false;
                userInfo.HoursToIgnoreMondaisThatYouHaveDone = 24 * 5;

                CollectionAssert.AreEquivalent(new [] { "chumon1", "chumon1", "d1-chumon2", "chumon1", },
                    userInfo.GetMondaiResultsThatYouHaveDoneToday().Select(x => x.MondaiId).ToArray());
            }
        }
        public void ChumonIdと同じHelpIdを見つけたら指定がなくても読み込む()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.AddFile(@"help\help0.png", fileName => new Bitmap(100, 100).Save(fileName, System.Drawing.Imaging.ImageFormat.Png));
                test.AddFile(@"help\chumon1.png", fileName => new Bitmap(100, 100).Save(fileName, System.Drawing.Imaging.ImageFormat.Png));
                test.Initialize();

                var window = test.Window;
                var helpDocumentSet = window.EPuzzleData.HelpDocumentSet;
                Assert.NotNull(helpDocumentSet);
                Assert.AreEqual("name0", helpDocumentSet.GetItem("help0").Name);

                var daimon = (Daimon)window.EPuzzleData.MondaiDocuments[0].GetItem("daimon1");
                var daimonState = new DaimonState(window, daimon);
                window.State = daimonState;
                var chumonButton = (ChumonButton)window.State.GetAllItems().OfType<ChumonButton>().First();
                var chumon = (Chumon)chumonButton.Chumon;
                Assert.AreEqual("chumon1", chumon.Id);

                window.State.CurrentItem = chumonButton;
                window.State.OnAction0();

                test.AddTime(10);
                window.Tick();
                test.AddTime(10);
                window.Tick();

                // help0
                {
                    Assert.IsInstanceOf<HelpItemState>(window.State);

                    Assert.AreEqual("help0", ((HelpItemState)window.State).HelpItem.Id);
                    var previousButton = window.State.GetAllItems().OfType<PreviousButton>().FirstOrDefault();
                    var nextButton = window.State.GetAllItems().OfType<NextButton>().FirstOrDefault();
                    Assert.Null(previousButton);
                    Assert.NotNull(nextButton);

                    window.State.CurrentItem = nextButton;
                    window.State.OnAction0();
                }
                // help1
                {
                    Assert.IsInstanceOf<HelpItemState>(window.State);

                    Assert.AreEqual("help1", ((HelpItemState)window.State).HelpItem.Id);
                    var previousButton = window.State.GetAllItems().OfType<PreviousButton>().FirstOrDefault();
                    var nextButton = window.State.GetAllItems().OfType<NextButton>().FirstOrDefault();
                    Assert.NotNull(previousButton);
                    Assert.NotNull(nextButton);

                    window.State.CurrentItem = nextButton;
                    window.State.OnAction0();
                }
                // chumon1
                {
                    Assert.IsInstanceOf<HelpItemState>(window.State);

                    Assert.AreEqual("chumon1", ((HelpItemState)window.State).HelpItem.Id);
                    var previousButton = window.State.GetAllItems().OfType<PreviousButton>().FirstOrDefault();
                    var nextButton = window.State.GetAllItems().OfType<NextButton>().FirstOrDefault();
                    Assert.NotNull(previousButton);
                    Assert.Null(nextButton);
                }
            }
        }
        public void NumberOfQuestionsThatYouHaveToDoTodayTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\Mondai3.xml", TestResources.Mondai03);
                test.AddFile(@"mondai\Mondai2.xml", TestResources.Mondai02);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocuments = window.EPuzzleData.MondaiDocuments;

                var tutor = new EPuzzleTutor(userInfo, mondaiDocuments, TimeSpan.FromHours(12d), 30);
                CollectionAssert.AreEqual(mondaiDocuments, tutor.MondaiDocuments);

                Assert.AreEqual(30, tutor.NumberOfQuestionsThatYouHaveToDoToday);
            /*				Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    tutor.NumberOfQuestionsThatYouHaveToDoToday = 0;
                });
                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    tutor.NumberOfQuestionsThatYouHaveToDoToday = -1;
                });*/

                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon1", "chumon1",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                //

                // tutor.NumberOfQuestionsThatYouHaveToDoToday = 1;
                TestUtility.SetValue(tutor, "NumberOfQuestionsThatYouHaveToDoToday", 1);

                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon1",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                //

                //tutor.NumberOfQuestionsThatYouHaveToDoToday = 30;
                TestUtility.SetValue(tutor, "NumberOfQuestionsThatYouHaveToDoToday", 30);

                {
                    var chumons = TestUtility.Invoke<IEnumerable<Chumon>>(tutor, "GetChumons").ToArray();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon1", "chumon1",
                    }, GetIds(chumons));

                    var t0 = new DateTime(2013, 6, 11, 0, 0, 0); // UTC
                    userInfo.MondaiResults.AddNew("d1_chumon1", t0, TimeSpan.FromSeconds(5d));
                    Assert.AreEqual("A", chumons.ElementAt(0).GetNewestGradeString(userInfo));
                    EPuzzleTime.Now = t0;
                }

                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon2", "chumon1",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                // tutor.NumberOfQuestionsThatYouHaveToDoToday = 1;
                TestUtility.SetValue(tutor, "NumberOfQuestionsThatYouHaveToDoToday", 1);

                CollectionAssert.AreEqual(Enumerable.Empty<string>(), GetIds(TestUtility.Inv(tutor, "GetChumons")));

                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon2",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons", false, 2)));

                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    TestUtility.Inv(tutor, "GetChumons", false, -1);
                });
                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    TestUtility.Inv(tutor, "GetChumons", false, 0);
                });
            }
        }
        public void Difficultyに依存するプロパティを正しく処理する()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;

                // daimon1, daimon2, ... , daimon6

                // Normal

                var daimon2 = (Daimon)mondaiDocument.GetAllItems().Where(x => "daimon2" == x.Id).First();
                Assert.NotNull(daimon2);
                Assert.AreEqual(Difficulty.Normal, userInfo.Difficulty);
                userInfo.SetLastDaimonInfo(daimon2);
                Assert.AreEqual("daimon2", userInfo.GetLastDaimonId(mondaiDocument.Id));

                // Hard

                userInfo.Difficulty = Difficulty.Hard;
                Assert.Null(userInfo.GetLastDaimonId(mondaiDocument.Id));
                var daimon3 = (Daimon)mondaiDocument.GetAllItems().Where(x => "daimon3" == x.Id).First();
                Assert.NotNull(daimon3);
                userInfo.SetLastDaimonInfo(daimon3);

                // Normal

                userInfo.Difficulty = Difficulty.Normal;
                Assert.AreEqual("daimon2", userInfo.GetLastDaimonId(mondaiDocument.Id));

                // Hard

                userInfo.Difficulty = Difficulty.Hard;
                Assert.AreEqual("daimon3", userInfo.GetLastDaimonId(mondaiDocument.Id));
            }
        }
        public void Test1()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();

                var window = test.Window;
                var daimons = window.EPuzzleData.CurrentMondaiDocument.GetAllItems().OfType<Daimon>().ToArray();
                Assert.AreEqual(7, daimons.Count());

                var windowState = new WindowState(window);
                window.State = windowState;
                var userInfo = window.EPuzzleData.CurrentUserInfo;

                var daimonButtonBox = new DaimonButtonBox(daimons, 0, userInfo);
                CollectionAssert.AreEqual(daimons, daimonButtonBox.Daimons);
                Assert.AreEqual(0, daimonButtonBox.DaimonIndex);
                window.State.Items.Add(daimonButtonBox);

                var daimonButtons = daimonButtonBox.Items.OfType<DaimonButton>();
                Assert.AreEqual(daimons.Count(), daimonButtons.Count());
                Assert.True(daimonButtons.All(x => DrawingObjectFloating.Left == x.Floating));

                daimonButtonBox.DaimonButtonSize = new SizeF(10, 20);
                Assert.True(daimonButtons.All(x => x.Size == new Size(10, 20)));

                daimonButtonBox.DaimonButtonMarginLeft = 8f;
                Assert.True(daimonButtons.All(x => x.MarginLeft == 8f));

                daimonButtonBox.DaimonButtonMarginTop = 8f;
                Assert.True(daimonButtons.All(x => x.MarginTop == 8f));

                daimonButtonBox.DaimonButtonMarginBottom = 8f;
                Assert.True(daimonButtons.All(x => x.MarginBottom == 8f));

                // ボーダーライン表示
            //				Assert.True(daimonButtons.All(x => x.BorderLine));

                daimonButtonBox.Refresh();

                var daimonButton = daimonButtons.First();
                Assert.AreEqual(daimonButton.OuterWidth * daimonButtons.Count() + daimonButtonBox.DaimonButtonMarginLeft, daimonButtonBox.Width);
                Assert.AreEqual(daimonButton.OuterHeight, daimonButtonBox.Height);

                // IsClickable
                CollectionAssert.AreEqual(new [] { false, false, false, false, false, false, false, }, daimonButtons.Select(x => x.IsClickable));

                test.Unlock(daimons[0]);
                CollectionAssert.AreEqual(new [] { false, false, true, true, true, true, true, }, daimons.Select(x => x.IsLocked(userInfo)));

                daimonButtonBox.Refresh();
                CollectionAssert.AreEqual(new [] { false, true, false, false, false, false, false, }, daimonButtons.Select(x => x.IsClickable));
                CollectionAssert.AreEqual(new [] { true, false, true, true, true, true, true, }, daimonButtons.Select(x => x.Monochrome));
            }
        }
        public void Test()
        {
            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>
            </chumon>
            </daimon>
            </mondaiDocument>";

            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\Mondai3.xml", xml);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                userInfo.TimeLimit.TimeLimitTweak = 2d;

                var mondaiDocument = window.EPuzzleData.MondaiDocuments.First();
                var chumon = (Chumon)mondaiDocument.GetItem("chumon1");
                Assert.NotNull(chumon);

                Assert.AreEqual(TimeSpan.FromSeconds(8d), chumon.GetTimeLimit(userInfo));
            }
        }
        public void HasGoldOrSilverMedalTest()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03);
                test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml);
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument;

                var chumon = (Chumon)mondaiDocument.Items.First().Items.First();
                CollectionAssert.IsEmpty(userInfo.GetMedals(chumon.Id));

                userInfo.Medals.Add(new Medal(chumon.Id, Difficulty.Normal));
                {
                    var medals = userInfo.GetMedals(chumon.Id);
                    var medal = medals.First();
                    Assert.AreEqual(1, medals.Count());
                    Assert.AreEqual(Difficulty.Normal, medal.Difficulty);
                    Assert.AreEqual(chumon.Id, medal.MondaiId);
                }

                userInfo.Medals.Add(new Medal(chumon.Id, Difficulty.Hard));
                {
                    var medals = userInfo.GetMedals(chumon.Id);
                    Assert.AreEqual(2, medals.Count());
                    CollectionAssert.AreEqual(new [] { chumon.Id, chumon.Id, }, medals.Select(x => x.MondaiId));
                    CollectionAssert.AreEquivalent(new [] { Difficulty.Normal, Difficulty.Hard, }, medals.Select(x => x.Difficulty));
                }

                // EigoTestMondaiを引数にとるバージョン

                {
                    var medals = userInfo.GetMedals(chumon);
                    Assert.AreEqual(2, medals.Count());
                    CollectionAssert.AreEqual(new [] { chumon.Id, chumon.Id, }, medals.Select(x => x.MondaiId));
                    CollectionAssert.AreEquivalent(new [] { Difficulty.Normal, Difficulty.Hard, }, medals.Select(x => x.Difficulty));
                }
            }
        }
        public void もっとやる係数の自動リセットテスト()
        {
            using (var test = new EPuzzleTestManager())
            {
                test.AddFile(@"mondai\mondai.xml", @"<?xml version=""1.0"" encoding=""utf-8""?>
            <mondai-document id=""doc1"" title=""DocumentB"">
            <daimon id=""d1"" title=""基礎I"">
            <chumon id=""c1"" title=""This is a pen."">
            <shomon id=""s1"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c2"" title=""This is a pen."">
            <shomon id=""s2"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c3"" title=""This is a pen."">
            <shomon id=""s3"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c4"" title=""This is a pen."">
            <shomon id=""s4"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c5"" title=""This is a pen."">
            <shomon id=""s5"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c6"" title=""This is a pen."">
            <shomon id=""s6"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c7"" title=""This is a pen."">
            <shomon id=""s7"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            <chumon id=""c8"" title=""This is a pen."">
            <shomon id=""s8"">
                <mondaibun>[英訳] これはボールです。</mondaibun>
                <seikai>This is a ball.</seikai>
                <word>This is</word>
                <word>a ball.</word>
            </shomon>
            </chumon>
            </daimon>
            </mondai-document>");
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondaiDocuments = window.EPuzzleData.MondaiDocuments;

                userInfo.UseNewMethodThatGetsChumonsThatYouHaveDoneToday = true;
                userInfo.TimeToChangeDay = new TimeSpan(3, 0, 0);

                // 期間における復習猶予期間の最大値を書き換える
                ((GradeProcessorB)userInfo.GradeProcessor).期間における復習猶予期間の最大値 = new []
                {
                    new Pair<TimeSpan, TimeSpan>(TimeSpan.FromHours(12d), TimeSpan.FromHours(12d)),
                };

                var tutor = new EPuzzleTutor(userInfo, mondaiDocuments, TimeSpan.FromHours(12d), 1);
                CollectionAssert.AreEqual(mondaiDocuments, tutor.MondaiDocuments);
                Assert.AreEqual(1, tutor.NumberOfQuestionsThatYouHaveToDoToday);
                Assert.AreEqual(TimeSpan.FromHours(12f), tutor.この時間以内の問題は無視する);

                var t0 = new DateTime(2014, 1, 1, 12, 0, 0, DateTimeKind.Local);
                var now = t0 + TimeSpan.FromDays(30d);

                userInfo.MondaiResults.AddNew("c1", t0, TimeSpan.FromSeconds(3d));
                userInfo.MondaiResults.AddNew("c2", t0 + TimeSpan.FromSeconds(1d), TimeSpan.FromSeconds(3d));
                userInfo.MondaiResults.AddNew("c3", t0 + TimeSpan.FromSeconds(2d), TimeSpan.FromSeconds(3d));
                userInfo.MondaiResults.AddNew("c4", t0 + TimeSpan.FromSeconds(3d), TimeSpan.FromSeconds(3d));
                userInfo.MondaiResults.AddNew("c5", t0 + TimeSpan.FromSeconds(4d), TimeSpan.FromSeconds(3d));
                userInfo.MondaiResults.AddNew("c6", t0 + TimeSpan.FromSeconds(5d), TimeSpan.FromSeconds(3d));
                userInfo.MondaiResults.AddNew("c7", t0 + TimeSpan.FromSeconds(6d), TimeSpan.FromSeconds(3d));
                userInfo.MondaiResults.AddNew("c8", t0 + TimeSpan.FromSeconds(7d), TimeSpan.FromSeconds(3d));

                EPuzzleTime.Now = now;

                CollectionAssert.AreEquivalent(new []
                {
                    "c1",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                userInfo.MondaiResults.AddNew("c1", now - TimeSpan.FromHours(1d), TimeSpan.FromSeconds(3d));

                CollectionAssert.IsEmpty(TestUtility.Inv(tutor, "GetChumons"));

                tutor.もっとやる係数++;
                Assert.AreEqual(2, tutor.もっとやる係数);

                CollectionAssert.AreEquivalent(new []
                {
                    "c2",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                userInfo.MondaiResults.AddNew("c2", now - TimeSpan.FromHours(1d), TimeSpan.FromSeconds(3d));

                tutor.もっとやる係数++;
                Assert.AreEqual(3, tutor.もっとやる係数);

                CollectionAssert.AreEquivalent(new []
                {
                    "c3",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                EPuzzleTime.Now += TimeSpan.FromDays(1d);

                CollectionAssert.AreEquivalent(new []
                {
                    "c3", "c4", "c5",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                Assert.AreEqual(3, tutor.もっとやる係数);

                tutor.もっとやる係数を適正値に修正();

                CollectionAssert.AreEquivalent(new []
                {
                    "c3",
                }, GetIds(TestUtility.Inv(tutor, "GetChumons")));

                Assert.AreEqual(1, tutor.もっとやる係数);
            }
        }