Esempio n. 1
0
        public void TestMethod2()
        {
            PBDQConfig     pC = conf.pBDQ;
            char           c;
            CharFormatting dummyCF = CharFormatting.NeutralCF;

            Assert.ThrowsException <ArgumentException>(() => pC.GetCfForPBDQButton(-1, out c));
            Assert.ThrowsException <ArgumentException>(() => pC.GetLetterForButtonNr(-1));
            Assert.ThrowsException <ArgumentException>(() => pC.UpdateLetter(-1, dummyCF));
            Assert.ThrowsException <ArgumentException>(() => pC.UpdateLetter(-1, 'z', dummyCF));
            Assert.ThrowsException <ArgumentException>(() => pC.GetCfForPBDQButton(PBDQConfig.nrButtons, out c));
            Assert.ThrowsException <ArgumentException>(() => pC.GetLetterForButtonNr(PBDQConfig.nrButtons));
            Assert.ThrowsException <ArgumentException>(() => pC.UpdateLetter(PBDQConfig.nrButtons, dummyCF));
            Assert.ThrowsException <ArgumentException>(() => pC.UpdateLetter(PBDQConfig.nrButtons, 'z', dummyCF));
        }
Esempio n. 2
0
        public void TestPBDQConfig()
        {
            PBDQConfig pc = new PBDQConfig();

            pc.UpdateLetter(3, 'e', TestTheText.fixCFs[1]);
            Assert.AreEqual(TestTheText.fixCFs[1], pc.GetCfForPBDQLetter('e'));
            Assert.AreEqual('e', pc.GetLetterForButtonNr(3));
            pc.UpdateLetter(4, 'f', TestTheText.fixCFs[2]);
            Assert.AreEqual(TestTheText.fixCFs[2], pc.GetCfForPBDQLetter('f'));
            pc.UpdateLetter(4, 'k', TestTheText.fixCFs[3]);
            Assert.AreEqual(TestTheText.fixCFs[3], pc.GetCfForPBDQLetter('k'));
            Assert.AreEqual(TestTheText.fixCFs[3], pc.GetCfForPBDQButton(4, out _));
            UndoFactory.UndoLastAction();
            Assert.AreEqual(TestTheText.fixCFs[2], pc.GetCfForPBDQButton(4, out _));
            UndoFactory.UndoLastAction();
            UndoFactory.UndoLastAction();
            Assert.AreEqual('q', pc.GetLetterForButtonNr(3));
            Assert.IsFalse(pc.markAsBlack);
            pc.SetMarkAsBlackTo(true);
            Assert.IsTrue(pc.markAsBlack);
            UndoFactory.UndoLastAction();
            Assert.IsFalse(pc.markAsBlack);
            UndoFactory.RedoLastCanceledAction();
            Assert.IsTrue(pc.markAsBlack);
            pc.UpdateLetter(4, 'k', TestTheText.fixCFs[3]);
            pc.Reset();
            Assert.IsFalse(pc.markAsBlack);
            Assert.AreEqual(' ', pc.GetLetterForButtonNr(4));
            UndoFactory.UndoLastAction();
            Assert.IsTrue(pc.markAsBlack);
            Assert.AreEqual(TestTheText.fixCFs[3], pc.GetCfForPBDQButton(4, out _));
            Assert.AreEqual('k', pc.GetLetterForButtonNr(4));
            UndoFactory.RedoLastCanceledAction();
            Assert.IsFalse(pc.markAsBlack);
            Assert.AreEqual(' ', pc.GetLetterForButtonNr(4));
        }
Esempio n. 3
0
        private void CheckConsistency(PBDQConfig pC)
        {
            List <char> letters = new List <char>();

            for (char ci = 'A'; ci <= 'Z'; ci++)
            {
                letters.Add(ci);
            }
            for (char ci = 'a'; ci <= 'z'; ci++)
            {
                letters.Add(ci);
            }
            Assert.AreEqual(52, letters.Count);
            CharFormatting cfOthers = pC.GetCfForPBDQLetter('#');

            Assert.AreEqual(cfOthers, pC.GetCfForPBDQLetter(PBDQConfig.inactiveLetter));

            for (int i = 0; i < PBDQConfig.nrButtons; i++)
            {
                char           c;
                CharFormatting cf = pC.GetCfForPBDQButton(i, out c);
                if (c == PBDQConfig.inactiveLetter)
                {
                    Assert.AreEqual(cfOthers, cf);
                }
                else
                {
                    Assert.AreNotEqual(PBDQConfig.inactiveLetter, c);
                    Assert.AreEqual(cf, pC.GetCfForPBDQLetter(c));
                    Assert.AreEqual(c, pC.GetLetterForButtonNr(i));
                    if (letters.Contains(c))
                    {
                        letters.Remove(c);
                    }
                }
            }


            foreach (char c2 in letters)
            {
                Assert.AreEqual(cfOthers, pC.GetCfForPBDQLetter(c2));
            }
        }