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 MottoyaruButtonTest()
        {
            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 tutorState = window.GetTutorState(window.EPuzzleData.MondaiDocuments.Select(x => x.Id).ToArray());
                var tutor = (EPuzzleTutor)TestUtility.GetValue(tutorState, "_tutor");
                Assert.NotNull(tutor);
                Assert.AreEqual(20, tutor.NumberOfQuestionsThatYouHaveToDoToday);

                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());

                    {
                        var mottoyaru = tutorState.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "mottoyaruButton" == x.Name);
                        Assert.False(mottoyaru.IsVisible);
                        Assert.False(mottoyaru.IsClickable);
                    }

            //					tutor.NumberOfQuestionsThatYouHaveToDoToday = 1;
                    TestUtility.SetValue(tutor, "NumberOfQuestionsThatYouHaveToDoToday", 1);
                    Assert.AreEqual(1, tutor.NumberOfQuestionsThatYouHaveToDoToday);
                    tutorState.Refresh();

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

                    {
                        var chumon = window.State.GetAllItems().OfType<ChumonButton>().First().Chumon;
                        Assert.AreEqual("d1_chumon1", chumon.Id);
                        var t0 = new DateTime(2013, 6, 17, 0, 0, 0); // UTC
                        userInfo.MondaiResults.AddNew(chumon.Id, t0, TimeSpan.FromSeconds(1d));
                        EPuzzleTime.Now = t0;
                        tutorState.Refresh();
                    }
                    CollectionAssert.AreEqual(Enumerable.Empty<string>(), window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());

                    {
                        var mottoyaru = tutorState.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "mottoyaruButton" == x.Name);
                        Assert.True(mottoyaru.IsVisible);
                        Assert.True(mottoyaru.IsClickable);
                        Assert.AreEqual("もっとやる (1回目)", mottoyaru.Text);
                    }
                    {
                        var mottoyaru = tutorState.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "mottoyaruButton" == x.Name);
                        window.State.CurrentItem = mottoyaru;
                        window.State.OnAction0();
                    }

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

                    {
                        var mottoyaru = tutorState.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "mottoyaruButton" == x.Name);
                        Assert.False(mottoyaru.IsVisible);
                        Assert.False(mottoyaru.IsClickable);
                        Assert.AreEqual("もっとやる (2回目)", mottoyaru.Text);
                    }
                    CollectionAssert.AreEqual(new []
                    {
                        "d1_chumon2",
                    }, window.State.GetAllItems().OfType<ChumonButton>().Select(x => x.Chumon.Id).ToArray());

                    // タイトルに戻って帰った来たとき、もっとやる係数がリセットされている不具合の修正
                    {
                        var backToStartGameStateButton = window.State.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "backToStartGameStateButton" == x.Name);
                        window.State.CurrentItem = backToStartGameStateButton;
                        window.State.OnAction0();
                        test.FoFi();

                        Assert.IsInstanceOf<StartGameState>(window.State);
                        var tutorButton = window.State.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "tutorButton" == x.Name);
                        window.State.CurrentItem = tutorButton;
                        window.State.OnAction0();
                        test.FoFi();

                        Assert.IsInstanceOf<TutorState>(window.State);
                        Assert.AreSame(tutorState, window.State);
                        var mottoyaru = window.State.GetAllItems().OfType<EigoTestButtonItem>().Single(x => "mottoyaruButton" == x.Name);
                        Assert.False(mottoyaru.IsVisible);
                        Assert.False(mottoyaru.IsClickable);
                        Assert.AreEqual("もっとやる (2回目)", mottoyaru.Text);
                    }
                }
            }
        }