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 問題がないときにKirokuBox2が表示される不具合()
        {
            using (var test = new EPuzzleTestManager())
            {
                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 t0 = new DateTime(2013, 8, 27, 0, 0, 0); // UTC
                EPuzzleTime.Now = t0;

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

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

                tutor.この時間以内の問題は無視する = TimeSpan.FromHours(12d);
                var tutorState = new TutorState(window, tutor);

                window.State = tutorState;
                Assert.IsInstanceOf<TutorState>(window.State);
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                    window.State.CurrentItem = chumonButtons.ElementAt(0);

                    Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);

                    // CurrentItemは先頭のChumon
                    Assert.NotNull(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);

                    var kirokuBox = (KirokuBox2)TestUtility.GetValue(tutorState, "_kirokuBox");
                    Assert.AreEqual("d1_chumon1", kirokuBox.Chumon.Id);
                }
                {
                    var upButton = window.State.GetAllItems().Where(x => "upButton" == x.Name).FirstOrDefault();
                    Assert.Null(upButton);
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.Null(downButton);
                }
            /*				{
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    Assert.False(tutorState.OrderByGradeStrings);
                    Assert.AreEqual("復習猶予期間順", orderByGradeStringsButton.Text);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                }
                {
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    Assert.True(tutorState.OrderByGradeStrings);
                    Assert.AreEqual("最新の成績順", orderByGradeStringsButton.Text);
                }
                {
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                }
                Assert.False(tutorState.OrderByGradeStrings);
                */

                // Chumon開始

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    window.State.CurrentItem = chumonButtons.First();
                    Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                }

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

                Assert.AreSame(tutorState, window.WindowStateWhichHasStartedChumon);

                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "This is" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "a notebook" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "." == x.Text).First();
                window.State.OnAction0();
                EPuzzleTime.Now += TimeSpan.FromSeconds(1d);
                window.State.Tick();
                window.State.Tick();

                test.FoFi();

                Assert.IsInstanceOf<ShomonState>(window.State);
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "This" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "is" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "a" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "ball" == x.Text).First();
                window.State.OnAction0();

            //				EPuzzleTime.Now += TimeSpan.FromSeconds(10d);

                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "." == x.Text).First();
                window.State.OnAction0();
                EPuzzleTime.Now += TimeSpan.FromSeconds(1d);
                window.State.Tick();
                window.State.Tick();

                test.FoFi();

                Assert.IsInstanceOf<ChumonResultState>(window.State);
                WindowState.NowObject.Now += TimeSpan.FromSeconds(10d);
                window.State.OnAction0();
                window.Tick();

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

                test.FoFi();

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

                {
                    CollectionAssert.IsEmpty(window.State.GetAllItems().OfType<ChumonButton>());
                    Assert.Null(window.State.GetAllItems().OfType<KirokuBox2>().First().Chumon);
                    Assert.IsNotInstanceOf<ChumonButton>(window.State.CurrentItem);
                }
            }
        }
        public void マウスホイールテスト()
        {
            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);
                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon1", "chumon1",
                }, window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());

                HelpWithScroll<Chumon> helpWithScroll = (HelpWithScroll<Chumon>)TestUtility.GetValue(tutorState, "_helpWithScroll");
                helpWithScroll.NumberOfItemsToBeShown = 1;
                tutorState.Refresh();

            //				Assert.AreEqual(0, tutorState.Index);
                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon1",
                }, window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());

                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);

                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon1",
                }, window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());

                // delta: -120

                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);

            //				Assert.AreEqual(1, helpWithScroll.Index);
                CollectionAssert.AreEqual(new []
                {
                    "chumon1",
                }, window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());

                // delta: -120

                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);
                window.MouseWheel(-120);

            //				Assert.AreEqual(1, tutorState.Index);
                CollectionAssert.AreEqual(new []
                {
                    "chumon1",
                }, window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());

                // delta: 120 x 2

                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);
                window.MouseWheel(120);

            //				Assert.AreEqual(0, tutorState.Index);
                CollectionAssert.AreEqual(new []
                {
                    "d1_chumon1",
                }, window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());
            }
        }
        public void ChumonButton記憶()
        {
            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.AddFile(@"help\help0.png", fileName => new Bitmap(100, 100).Save(fileName, System.Drawing.Imaging.ImageFormat.Png));
                test.Initialize();
                var window = test.Window;
                var userInfo = window.EPuzzleData.CurrentUserInfo;
                var mondai2 = window.EPuzzleData.MondaiDocuments[0];
                var mondai3 = window.EPuzzleData.MondaiDocuments[1];
                var t0 = new DateTime(2013, 9, 5, 0, 0, 0); // UTC
                EPuzzleTime.Now = t0;

            //				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 chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon1", "chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                    window.State.CurrentItem = chumonButtons.ElementAt(0);

                    Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);

                    // CurrentItemは先頭のChumon
                    Assert.NotNull(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);

                    var kirokuBox = (KirokuBox2)TestUtility.GetValue(tutorState, "_kirokuBox");
                    Assert.NotNull(kirokuBox);
                    Assert.NotNull(kirokuBox.Chumon);
                    Assert.AreEqual("d1_chumon1", kirokuBox.Chumon.Id);
                }
                {
                    var upButton = window.State.GetAllItems().Where(x => "upButton" == x.Name).FirstOrDefault();
                    Assert.Null(upButton);
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.Null(downButton);
                }
            /*				{
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                }*/

                // Chumon開始

                userInfo.MondaiResults.AddNew("d1_chumon1", t0 - TimeSpan.FromDays(2d), TimeSpan.FromSeconds(1d));
                tutorState.Refresh();

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1", "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    window.State.CurrentItem = chumonButtons.Skip(2).First();
                    Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);
                }

                var currentItemInfo = window.State.SaveCurrentItem();
                Assert.IsInstanceOf<ChumonButton>(currentItemInfo.Item);
                Assert.AreEqual("d1_chumon1", currentItemInfo.Item.Name);

                window.State.OnAction0();
                Assert.IsInstanceOf<ClickDeKaishiState>(window.State);
                window.State.OnAction3();
                Assert.IsInstanceOf<TutorState>(window.State);
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1", "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());

                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1", "d1_chumon1",
                    }, chumonButtons.Select(x => x.Name));
                }
                Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);
            }
        }
        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.AddFile(@"help\help0.png", fileName => new Bitmap(100, 100).Save(fileName, System.Drawing.Imaging.ImageFormat.Png));
                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 chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon1", "chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                    window.State.CurrentItem = chumonButtons.ElementAt(0);

                    Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);

                    // CurrentItemは先頭のChumon
                    Assert.NotNull(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);

                    var kirokuBox = (KirokuBox2)TestUtility.GetValue(tutorState, "_kirokuBox");
                    Assert.AreEqual("d1_chumon1", kirokuBox.Chumon.Id);
                }
                {
                    var upButton = window.State.GetAllItems().Where(x => "upButton" == x.Name).FirstOrDefault();
                    Assert.Null(upButton);
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.Null(downButton);
                }
            /*				{
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    Assert.False(tutorState.OrderByGradeStrings);
                    Assert.AreEqual("復習猶予期間順", orderByGradeStringsButton.Text);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                }
                {
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    Assert.True(tutorState.OrderByGradeStrings);
                    Assert.AreEqual("最新の成績順", orderByGradeStringsButton.Text);
                }
                {
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                }

                Assert.False(tutorState.OrderByGradeStrings);
                */

                // Chumon開始

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    window.State.CurrentItem = chumonButtons.First();
                    Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                }

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

                Assert.AreSame(tutorState, window.WindowStateWhichHasStartedChumon);

                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "This is" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "a notebook" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "." == x.Text).First();
                window.State.OnAction0();
                EPuzzleTime.Now += TimeSpan.FromSeconds(1d);
                window.State.Tick();
                window.State.Tick();

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

                Assert.IsInstanceOf<ShomonState>(window.State);
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "This" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "is" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "a" == x.Text).First();
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "ball" == x.Text).First();
                window.State.OnAction0();

                EPuzzleTime.Now += TimeSpan.FromSeconds(10d);

                window.State.CurrentItem = window.State.GetAllItems().Where(x => x is WordCard && "." == x.Text).First();
                window.State.OnAction0();
                EPuzzleTime.Now += TimeSpan.FromSeconds(1d);
                window.State.Tick();
                window.State.Tick();

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

                Assert.IsInstanceOf<ChumonResultState>(window.State);
                WindowState.NowObject.Now += TimeSpan.FromSeconds(10d);
                window.State.OnAction0();
                window.Tick();

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

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

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

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    Assert.AreEqual("B", chumonButtons.First(x => "d1_chumon1" == x.Chumon.Id).Chumon.GetNewestGradeString(userInfo));
                    Assert.AreEqual("-", chumonButtons.First(x => "d1_chumon2" == x.Chumon.Id).Chumon.GetNewestGradeString(userInfo));
                    Assert.AreEqual("-", chumonButtons.First(x => "chumon1" == x.Chumon.Id).Chumon.GetNewestGradeString(userInfo));
                }
                HelpWithScroll<Chumon> helpWithScroll = (HelpWithScroll<Chumon>)TestUtility.GetValue(tutorState, "_helpWithScroll");
                {
                    Assert.AreEqual(0, helpWithScroll.NumberOfUpperItems);
                    Assert.AreEqual(-15, helpWithScroll.NumberOfLowerItems);
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1", "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());

                    Assert.NotNull(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);
                }

                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    helpWithScroll.NumberOfItemsToBeShown = 0;
                });

                helpWithScroll.NumberOfItemsToBeShown = 2;
                tutorState.Refresh();

                {
                    Assert.AreEqual(0, helpWithScroll.NumberOfUpperItems);
                    Assert.AreEqual(1, helpWithScroll.NumberOfLowerItems);
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var upButton = window.State.GetAllItems().Where(x => "upButton" == x.Name).FirstOrDefault();
                    Assert.Null(upButton);
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.NotNull(downButton);

                    window.State.CurrentItem = downButton;
                    window.State.OnAction0();
                }

                {
                    Assert.AreEqual(1, helpWithScroll.NumberOfUpperItems);
                    Assert.AreEqual(0, helpWithScroll.NumberOfLowerItems);
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "chumon1", "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var upButton = window.State.GetAllItems().Where(x => "upButton" == x.Name).FirstOrDefault();
                    Assert.NotNull(upButton);
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.Null(downButton);

                    window.State.CurrentItem = upButton;
                    window.State.OnAction0();
                }

                {
                    Assert.AreEqual(0, helpWithScroll.NumberOfUpperItems);
                    Assert.AreEqual(1, helpWithScroll.NumberOfLowerItems);
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var upButton = window.State.GetAllItems().Where(x => "upButton" == x.Name).FirstOrDefault();
                    Assert.Null(upButton);
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.NotNull(downButton);
                }

            /*				Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    helpWithScroll.Index = 0;
                    helpWithScroll.Index--;
                });
                Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    helpWithScroll.Index = 1;
                    helpWithScroll.Index++;
                });*/

                helpWithScroll.ScrollUp(100);
            //				helpWithScroll.Index = 0;
                tutorState.Refresh();
                {
                    var upButton = window.State.GetAllItems().Where(x => "upButton" == x.Name).FirstOrDefault();
                    Assert.Null(upButton);
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.NotNull(downButton);
                }

                // Ctrl + Down
                window.State.OnActionDown();

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

                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "chumon1", "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                window.State.OnActionDown();
                window.State.OnActionDown();
                window.State.OnActionDown();

                // Ctrl + Up
                window.State.OnActionUp();

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                window.State.OnActionUp();
                window.State.OnActionUp();
                window.State.OnActionUp();

                helpWithScroll.NumberOfItemsToBeShown = 3;
                tutorState.Refresh();

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2", "chumon1", "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());

                    CollectionAssert.AreEqual(new []
                    {
                        "-", "-", "B",
                    }, chumonButtons.Select(x => x.Chumon.GetGradeString(userInfo)));
                }

            /*				Assert.False(tutorState.OrderByGradeStrings);

                {
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                    Assert.True(tutorState.OrderByGradeStrings);

                    orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    Assert.AreEqual("最新の成績順", orderByGradeStringsButton.Text);
                }
                {
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                    Assert.False(tutorState.OrderByGradeStrings);

                    orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    Assert.AreEqual("復習猶予期間順", orderByGradeStringsButton.Text);
                }
                {
                    var orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    window.State.CurrentItem = orderByGradeStringsButton;
                    window.State.OnAction0();
                    Assert.True(tutorState.OrderByGradeStrings);

                    orderByGradeStringsButton = window.State.GetAllItems().First(x => "orderByGradeStringsButton" == x.Name);
                    Assert.AreEqual("最新の成績順", orderByGradeStringsButton.Text);
                }*/

                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGradeButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("成績順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);

                    // 成績順ボタンを押下
                    window.State.CurrentItem = button;
                    window.State.OnAction0();
                }

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon1", "d1_chumon2", "chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());

                    CollectionAssert.AreEqual(new []
                    {
                        "B", "-", "-",
                    }, chumonButtons.Select(x => x.Chumon.GetGradeString(userInfo)));
                }

            //				helpWithScroll.NumberOfItemsToBeShown = 1;
                TestUtility.GetValue(window.State, "_gradeScrollHelper").NumberOfItemsToBeShown = 1;
                tutorState.Refresh();

                window.State.OnActionUp();
                window.State.OnActionUp();
                window.State.OnActionUp();
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.NotNull(downButton);
                    window.State.CurrentItem = downButton;
                    window.State.OnAction0();
                }
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());

                    var downButton = window.State.GetAllItems().Where(x => "downButton" == x.Name).FirstOrDefault();
                    Assert.NotNull(downButton);
                    Assert.AreSame(downButton, window.State.CurrentItem);
                }
            }
        }
        public void ShomonStateの戻るボタンの修正()
        {
            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 chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon1", "chumon1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                    window.State.CurrentItem = chumonButtons.ElementAt(0);

                    Assert.IsInstanceOf<ChumonButton>(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);

                    // CurrentItemは先頭のChumon
                    Assert.NotNull(window.State.CurrentItem);
                    Assert.AreEqual("d1_chumon1", ((ChumonButton)window.State.CurrentItem).Chumon.Id);
                }

                // Chumon開始

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

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

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

                Assert.IsInstanceOf<TutorState>(window.State);
            }
        }
        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>
            </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;
                userInfo.GradeProcessor = new TestGradeProcessor();
                Assert.IsInstanceOf<GradeProcessorB>(userInfo.GradeProcessor);

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

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

                var t0 = new DateTime(2013, 9, 5, 0, 0, 0); // UTC
                var t1 = t0 + TimeSpan.FromMinutes(10d);
                var t2 = t1 + TimeSpan.FromMinutes(10d);
                EPuzzleTime.Now = t2 + TimeSpan.FromDays(1d);

                window.State = tutorState;
                Assert.IsInstanceOf<TutorState>(window.State);
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "c1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }

                // byDateYouDidThemButton
                // byGracePriodButton
                // byGradeButton

                userInfo.MondaiResults.AddNew("c1", t2, TimeSpan.FromSeconds(1d));
                userInfo.MondaiResults.AddNew("c2", t1, TimeSpan.FromSeconds(1.1d));
                userInfo.MondaiResults.AddNew("c3", t0, TimeSpan.FromSeconds(1.2d));

                var c1 = (Chumon)mondaiDocument.GetItem("c1");
                var c2 = (Chumon)mondaiDocument.GetItem("c2");
                var c3 = (Chumon)mondaiDocument.GetItem("c3");

                tutorState.Refresh();
                Assert.AreEqual(TutorStateSortType.GracePriod, TestUtility.GetValue(tutorState, "_sortType"));
                Assert.AreEqual(TimeSpan.FromDays(2d), c1.復習までの猶予期間を取得(userInfo));
                Assert.AreEqual(TimeSpan.FromDays(1d), c2.復習までの猶予期間を取得(userInfo));
                Assert.AreEqual(TimeSpan.FromDays(3d), c3.復習までの猶予期間を取得(userInfo));
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "c2", "c1", "c3",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGracePriodButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("猶予順", button.Text);
                    Assert.False(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byDateYouDidThemButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("試験順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGradeButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("成績順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);

                    // 成績順ボタンを押下
                    window.State.CurrentItem = button;
                    window.State.OnAction0();
                }

                Assert.AreEqual(TutorStateSortType.Grade, TestUtility.GetValue(tutorState, "_sortType"));
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "c3", "c2", "c1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGracePriodButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("猶予順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGradeButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("成績順", button.Text);
                    Assert.False(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byDateYouDidThemButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("試験順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);

                    // 試験順ボタンを押下
                    window.State.CurrentItem = button;
                    window.State.OnAction0();
                }

                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "c1", "c2", "c3",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                Assert.AreEqual(TutorStateSortType.DateYouDidThem, TestUtility.GetValue(tutorState, "_sortType"));
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGradeButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("成績順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byDateYouDidThemButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("試験順", button.Text);
                    Assert.False(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGracePriodButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("猶予順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);

                    // 復習猶予期間順ボタンを押下
                    window.State.CurrentItem = button;
                    window.State.OnAction0();
                }

                Assert.AreEqual(TutorStateSortType.GracePriod, TestUtility.GetValue(tutorState, "_sortType"));
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "c2", "c1", "c3",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGracePriodButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("猶予順", button.Text);
                    Assert.False(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byDateYouDidThemButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("試験順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);
                }
                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGradeButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("成績順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);
                }

                // 各ボタンで、並び順が保存されているかどうかテストする。
                {
                    var scrollHelper = TestUtility.GetValue(tutorState, "_helpWithScroll");
                    scrollHelper.NumberOfItemsToBeShown = 2;
                    tutorState.Refresh();
                    Assert.AreEqual(0, TestUtility.GetValue(scrollHelper, "_index"));
                }
                Assert.AreEqual(TutorStateSortType.GracePriod, TestUtility.GetValue(tutorState, "_sortType"));
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "c2", "c1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }

                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGradeButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("成績順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);

                    // 成績順ボタンを押下
                    window.State.CurrentItem = button;
                    window.State.OnAction0();
                }

                // 成績順ボタン
                Assert.AreEqual(TutorStateSortType.Grade, TestUtility.GetValue(tutorState, "_sortType"));

                {
                    var scrollHelper = TestUtility.GetValue(tutorState, "_helpWithScroll");
                    scrollHelper.NumberOfItemsToBeShown = 2;
                    tutorState.Refresh();
                    Assert.AreEqual(0, TestUtility.GetValue(scrollHelper, "_index"));
                }
                {
                    var downButton = window.State.GetAllItems().FirstOrDefault(x => "downButton" == x.Name);

                    // 下スクロールボタンを押下
                    window.State.CurrentItem = downButton;
                    window.State.OnAction0();
                }
                {
                    var chumonButtons = window.State.GetAllItems().OfType<ChumonButton>();
                    CollectionAssert.AreEqual(new []
                    {
                        "c2", "c1",
                    }, chumonButtons.Select(x => x.Chumon.Id).ToArray());
                }

                {
                    var scrollHelper = TestUtility.GetValue(tutorState, "_helpWithScroll");
                    scrollHelper.NumberOfItemsToBeShown = 2;
                    tutorState.Refresh();

                    Assert.AreSame(scrollHelper, TestUtility.GetValue(tutorState, "_gradeScrollHelper"));
                    Assert.AreEqual(TutorStateSortType.Grade, TestUtility.GetValue(tutorState, "_sortType"));
                    Assert.AreEqual(1, TestUtility.GetValue(scrollHelper, "_index"));
                }

                {
                    var button = window.State.GetAllItems().FirstOrDefault(x => "byGracePriodButton" == x.Name);
                    Assert.NotNull(button);
                    Assert.AreEqual("猶予順", button.Text);
                    Assert.True(button.IsClickable);
                    Assert.True(button.IsVisible);

                    // 復習猶予期間順ボタンを押下
                    window.State.CurrentItem = button;
                    window.State.OnAction0();
                }

                // 復習猶予期間順ボタン
                Assert.AreEqual(TutorStateSortType.GracePriod, TestUtility.GetValue(tutorState, "_sortType"));
                {
                    var scrollHelper = TestUtility.GetValue(tutorState, "_helpWithScroll");
                    scrollHelper.NumberOfItemsToBeShown = 2;
                    tutorState.Refresh();

                    // 成績順ボタンを押下時に下スクロールしても、このボタンでスクロール位置が保存されているかどうか確認
                    Assert.AreEqual(0, TestUtility.GetValue(scrollHelper, "_index"));
                }
            }
        }