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 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 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 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 ヘルプの表示は初回のみ()
        {
            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 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 カード分割要素のあるShomonStateで正解判定がうまく働かない不具合の修正()
        {
            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 shomon = (Shomon)window.EPuzzleData.MondaiDocuments[0].GetItem("4-1-1");
                Assert.AreEqual("4-1-1", shomon.Id);
            //				var shomonState = window.EPuzzleData.CurrentUserInfo.Factory.CreateShomonState(window, shomon);
                var shomonState = (ShomonState)window.CreateShomonState(shomon);
                window.State = shomonState;
                Assert.AreSame(shomon, shomonState.Shomon);

                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "Feb" == x.Text);
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "ru" == x.Text);
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "ar" == x.Text);
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "y" == x.Text);
                window.State.OnAction0();

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

                var kaitouBox = shomonState.GetAllItems().First(x => "kaitouBox" == x.Name);
                var mondaiWords = kaitouBox.GetAllItems().OfType<WordCard>().Select(x => x.MondaiWord).ToArray();
                CollectionAssert.AllItemsAreNotNull(mondaiWords);
                var text = MondaiWord.Join(mondaiWords);
                Assert.AreEqual(text, shomonState.Shomon.CorrectAnswers.First().Text);

            /*				{
                    var wordCards = kaitouBox.GetAllItems().OfType<WordCard>().ToArray();
                    Assert.AreEqual(4, wordCards.Count());
                    var wordCards1 = wordCards.Where(x => x.IsClickable).ToArray();
                    Assert.AreEqual(4, wordCards1.Count());

                    var mondaiWords01 = wordCards1.Select(x => x.MondaiWord).ToArray();

                    CollectionAssert.AreEqual(new []
                    {
                        new MondaiWord("Feb", false, true),
                        new MondaiWord("ru", true, true),
                        new MondaiWord("ar", true, true),
                        new MondaiWord("y", true, false),
                    }, mondaiWords01);

                    Assert.AreEqual("February", MondaiWord.Join(mondaiWords01));

                }*/

                Assert.True(shomonState.正解判定());

                Assert.IsInstanceOf<FadeoutState>(window.State);
                test.AddTime(10d);
                window.Tick();
                Assert.IsInstanceOf<FadeinState>(window.State);
                test.AddTime(10d);
                window.Tick();

                Assert.IsInstanceOf<ChumonResultState>(window.State);
            }
        }
        public void ShomonStateでカードを元に戻すとき前のカードが移動中だと初期値が異常()
        {
            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 shomon = (Shomon)window.EPuzzleData.MondaiDocuments[0].GetItem("1-1-1");
                Assert.AreEqual("1-1-1", shomon.Id);
            //				var shomonState = window.EPuzzleData.CurrentUserInfo.Factory.CreateShomonState(window, shomon);
                var shomonState = window.CreateShomonState(shomon);
                window.State = shomonState;
                Assert.AreSame(shomon, shomonState.Shomon);

                var a = window.State.GetAllItems().OfType<WordCard>().First(x => "This" == x.Text);
                var b = window.State.GetAllItems().OfType<WordCard>().First(x => "is" == x.Text);

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

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

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

                var kaitouBox = window.State.GetAllItems().First(x => "kaitouBox" == x.Name);
                var aa = kaitouBox.GetAllItems().First(x => "This" == x.Text);
                var bb = kaitouBox.GetAllItems().First(x => "is" == x.Text);
                Assert.AreEqual(2, window.State.GetAllItems().Count(x => "This" == x.Text));
                Assert.AreEqual(2, window.State.GetAllItems().Count(x => "is" == x.Text));

                // "is"カードを戻す
                Assert.AreEqual(2, window.State.GetAllItems().OfType<WordCard>().Count(x => "is" == x.Text));
                window.State.OnAction1();
                Assert.AreEqual(3, window.State.GetAllItems().OfType<WordCard>().Count(x => "is" == x.Text));

                test.AddTime(((ShomonState)window.State).カード移動時間 / (1000d * 2d));
                window.Tick();
                Assert.AreEqual(3, window.State.GetAllItems().OfType<WordCard>().Count(x => "is" == x.Text));

                // "This"カードを戻す
                Assert.AreEqual(2, window.State.GetAllItems().OfType<WordCard>().Count(x => "This" == x.Text));
                window.State.OnAction1();
                Assert.AreEqual(3, window.State.GetAllItems().OfType<WordCard>().Count(x => "This" == x.Text));
            }
        }
        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 shomon = (Shomon)window.EPuzzleData.MondaiDocuments[0].GetItem("1-1-1");
                Assert.AreEqual("1-1-1", shomon.Id);
            //				var shomonState = window.EPuzzleData.CurrentUserInfo.Factory.CreateShomonState(window, shomon);
                var shomonState = (ShomonState)window.CreateShomonState(shomon);
                window.State = shomonState;
                Assert.AreSame(shomon, shomonState.Shomon);

                var button0 = window.State.GetAllItems().OfType<EigoTestButtonItem>().First(x => "showCorrectAnswer" == x.Name);
                window.State.CurrentItem = button0;
                window.State.OnAction0();

                Assert.IsInstanceOf<InformationState>(window.State);
                Assert.AreEqual(@"This is a notebook.", ((InformationState)window.State).Text);
                var okButton = window.State.GetAllItems().OfType<EigoTestButtonItem>().First(x => "ok" == x.Name);
                window.State.CurrentItem = okButton;
                window.State.OnAction0();

                Assert.AreSame(shomonState, window.State);
                Assert.True(TestUtility.GetValue(shomonState, "_userHasSeenCorrectAnswer"));

                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "This" == x.Text);
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "is" == x.Text);
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "a notebook" == x.Text);
                window.State.OnAction0();
                window.State.CurrentItem = window.State.GetAllItems().OfType<WordCard>().First(x => "." == x.Text);
                window.State.OnAction0();

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

                Assert.IsInstanceOf<FadeoutState>(window.State);
                test.AddTime(10d);
                window.Tick();
                Assert.IsInstanceOf<FadeinState>(window.State);
                test.AddTime(10d);
                window.Tick();

                Assert.IsInstanceOf<ShomonState>(window.State);
                Assert.AreEqual("1-1-2", ((ShomonState)window.State).Shomon.Id);
            }
        }
        public void x日前表示テスト()
        {
            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 = mondaiDocument.GetItem("d1_chumon1");

                var t0 = new DateTime(2012, 12, 30, 9, 0, 0, DateTimeKind.Local);
                test.Now = t0;
                userInfo.MondaiResults.AddNew(chumon.Id, t0, TimeSpan.FromHours(1d));

                test.AddTime(TimeSpan.FromHours(5d));
                Assert.AreEqual("5時間前", userInfo.MondaiResults.GetOldest(chumon.Id).x日前表示);

                test.AddTime(TimeSpan.FromDays(1d));
                Assert.AreEqual("1日前", userInfo.MondaiResults.GetOldest(chumon.Id).x日前表示);

                test.AddTime(TimeSpan.FromDays(1d));
                Assert.AreEqual("2日前", userInfo.MondaiResults.GetOldest(chumon.Id).x日前表示);
            }
        }