示例#1
0
        public void TestOutOfRange()
        {
            ColConfWin ccw = conf.colors[PhonConfType.phonemes];

            Assert.ThrowsException <KeyNotFoundException>(() => ccw.GetCheck("farfelu"));
            Assert.ThrowsException <ArgumentNullException>(() => ccw.GetCheck(null));

            Assert.ThrowsException <KeyNotFoundException>(() => ccw.GetCF("farfelu"));
            Assert.ThrowsException <ArgumentNullException>(() => ccw.GetCF(null));

            Assert.ThrowsException <ArgumentOutOfRangeException>(()
                                                                 => ccw.SetCbxAndCF("farfelu", CharFormatting.BlackCF));
            Assert.ThrowsException <ArgumentNullException>(()
                                                           => ccw.SetCbxAndCF(null, CharFormatting.BlackCF));
            Assert.ThrowsException <ArgumentNullException>(()
                                                           => ccw.SetCbxAndCF("a", null));

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => ccw.ClearSon("farfelu"));
            Assert.ThrowsException <ArgumentNullException>(() => ccw.ClearSon(null));

            Assert.ThrowsException <ArgumentOutOfRangeException>(()
                                                                 => ccw.SetCFSon("farfelu", CharFormatting.BlackCF));
            Assert.ThrowsException <ArgumentNullException>(()
                                                           => ccw.SetCFSon(null, CharFormatting.BlackCF));
            Assert.ThrowsException <ArgumentNullException>(()
                                                           => ccw.SetCFSon("a", null));

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => ccw.SetChkSon("farfelu", false));
            Assert.ThrowsException <ArgumentNullException>(() => ccw.SetChkSon(null, true));
        }
示例#2
0
        public void TestColConfWinUndo_3()
        {
            ColConfWin ccw = new ColConfWin(PhonConfType.phonemes);

            ccw.SetCeras();
            Assert.AreEqual(ColConfWinTest.cfAN, ccw.GetCF("an"));
            ccw.SetCbxAndCF("m", ColConfWinTest.cfBLEUCLAIR);
            Assert.AreEqual(ColConfWinTest.cfBLEUCLAIR, ccw.GetCF("m"));
            Assert.IsTrue(ccw.GetCheck("m"));
            ccw.SetCFSon("m", ColConfWinTest.cfON);
            Assert.AreEqual(ColConfWinTest.cfON, ccw.GetCF("m"));
            ccw.IllRuleToUse = ColConfWin.IllRule.lirecouleur;
            Assert.AreEqual(ColConfWin.IllRule.lirecouleur, ccw.IllRuleToUse);
            ccw.SetDefaultBehaviourTo(ColConfWin.DefBeh.noir);
            Assert.AreEqual(ColConfWin.DefBeh.noir, ccw.defBeh);
            ccw.Reset();
            Assert.AreEqual(ColConfWinTest.cfeRose, ccw.GetCF("é"));
            Assert.IsFalse(ccw.GetCheck("m"));
            Assert.AreEqual(ColConfWin.IllRule.ceras, ccw.IllRuleToUse);
            Assert.AreEqual(ColConfWin.DefBeh.transparent, ccw.defBeh);
            UndoFactory.UndoLastAction();
            Assert.AreEqual(ColConfWinTest.cfON, ccw.GetCF("m"));
            Assert.IsTrue(ccw.GetCheck("m"));
            Assert.AreEqual(ColConfWin.IllRule.lirecouleur, ccw.IllRuleToUse);
            Assert.AreEqual(ColConfWin.DefBeh.noir, ccw.defBeh);
        }
示例#3
0
        public void TestColConfWinUndo_1()
        {
            ColConfWin ccw = new ColConfWin(PhonConfType.phonemes);

            ccw.SetCeras();
            Assert.AreEqual(ColConfWinTest.cfAN, ccw.GetCF("an"));
            ccw.SetCbxAndCF("m", ColConfWinTest.cfBLEUCLAIR);
            Assert.AreEqual(ColConfWinTest.cfBLEUCLAIR, ccw.GetCF("m"));
            Assert.IsTrue(ccw.GetCheck("m"));
            ccw.SetCFSon("m", ColConfWinTest.cfON);
            Assert.AreEqual(ColConfWinTest.cfON, ccw.GetCF("m"));
            UndoFactory.UndoLastAction();
            Assert.AreEqual(ColConfWinTest.cfBLEUCLAIR, ccw.GetCF("m"));
            UndoFactory.UndoLastAction();
            Assert.AreEqual(ColConfWinTest.cfBlack, ccw.GetCF("m"));
            Assert.IsFalse(ccw.GetCheck("m"));
            UndoFactory.RedoLastCanceledAction();
            Assert.AreEqual(ColConfWinTest.cfBLEUCLAIR, ccw.GetCF("m"));
            Assert.IsTrue(ccw.GetCheck("m"));
            UndoFactory.UndoLastAction();
            Assert.AreEqual(ColConfWinTest.cfe, ccw.GetCF("é"));
            UndoFactory.UndoLastAction();
            Assert.AreEqual(ColConfWinTest.cfeRose, ccw.GetCF("é"));
            ccw.SetChkSon("é", false);
            Assert.IsFalse(ccw.GetCheck("é"));
            UndoFactory.UndoLastAction();
            Assert.IsTrue(ccw.GetCheck("é"));
        }
示例#4
0
        public void TestFormatage1()
        {
            UnsetBehConf uB  = conf.unsetBeh;
            ColConfWin   ccw = conf.colors[PhonConfType.phonemes];
            SylConfig    sC  = conf.sylConf;

            RGB            color   = new RGB(25, 100, 200);
            RGB            hiColor = new RGB(200, 100, 25);
            CharFormatting cfAll   = new CharFormatting(true, true, true, true, true, color, true, hiColor);

            ccw.SetCbxAndCF("m", cfAll);

            TestTheText ttt = new TestTheText(text1);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, true);
            ttt.AssertItalic(0, true);
            ttt.AssertUnderline(0, true);
            ttt.AssertColor(0, color);
            ttt.AssertChangeHilight(0, true);
            ttt.AssertHilightColor(0, hiColor);
            ttt.AssertBold(10, true); // La config par défaut fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ccw.SetCerasRose();
            uB.SetCbuFlag("Bold", true);
            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, true);
            ttt.AssertUnderline(0, true);
            ttt.AssertColor(0, color);
            ttt.AssertChangeHilight(0, true);
            ttt.AssertHilightColor(0, hiColor);
            ttt.AssertBold(10, true); // Ceras rosé fait ça.
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("All", true);
            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, false);
            ttt.AssertUnderline(0, false);
            ttt.AssertColor(0, TestTheText.black);
            ttt.AssertChangeHilight(0, false);
            ttt.AssertBold(10, true); // Ceras rosé fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ttt.ColorizePhons(conf, PhonConfType.muettes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, false);
            ttt.AssertUnderline(0, false);
            ttt.AssertColor(0, TestTheText.black);
            ttt.AssertChangeHilight(0, false);
            ttt.AssertBold(10, false);
            ttt.AssertColor(10, TestTheText.black);
        }
示例#5
0
        private Dictionary <string, CharFormatting> SetTestConfig(ColConfWin ccw)
        {
            Dictionary <string, CharFormatting> toReturn = new Dictionary <string, CharFormatting>();
            int i = 0;

            foreach (string son in ColConfWin.sonsValides)
            {
                ccw.SetCbxAndCF(son, TestTheText.fixCFs[i]);
                Assert.IsTrue(ccw.GetCheck(son));
                Assert.AreEqual(TestTheText.fixCFs[i], ccw.GetCF(son));
                toReturn.Add(son, TestTheText.fixCFs[i]);
                i++;
            }
            return(toReturn);
        }
示例#6
0
        public void TestFormatage2()
        {
            UnsetBehConf uB  = conf.unsetBeh;
            ColConfWin   ccw = conf.colors[PhonConfType.phonemes];
            SylConfig    sC  = conf.sylConf;

            RGB            color   = new RGB(25, 100, 200);
            RGB            hiColor = new RGB(200, 100, 25);
            CharFormatting cfAll   = new CharFormatting(true, true, true, true, true, color, true, hiColor);

            ccw.SetCbxAndCF("p", cfAll);
            TestTheText ttt = new TestTheText(text1);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, true);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true); // La config par défaut fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ttt.MarkLetters(conf); // ça ne devrait pas toucher au P majuscule...
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, true);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("Italic", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("Underline", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, false);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("All", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, false);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, false);
            ttt.AssertColor(9, TestTheText.black);
            ttt.AssertChangeHilight(9, false);
            ttt.AssertBold(10, false);
            ttt.AssertColor(10, TestTheText.black);
        }
示例#7
0
        public void TestEvents2()
        {
            ColConfWin ccw = conf.colors[PhonConfType.phonemes];
            int        i   = 0;

            foreach (string son in ColConfWin.sonsValides)
            {
                ResetEventCounters();
                bool prevCbxVal = ccw.GetCheck(son);
                if (!prevCbxVal)
                {
                    ccw.SetChkSon(son, true);
                }
                CharFormatting prevCF = ccw.GetCF(son);
                if (!prevCbxVal)
                {
                    ccw.SetChkSon(son, false);
                }

                ResetEventCounters();
                ccw.ClearSon(son);
                if (prevCbxVal)
                {
                    Assert.AreEqual(1, SonCBModifiedEvents.Count);
                    Assert.AreEqual(son, SonCBModifiedEvents[0].son);
                    Assert.AreEqual(PhonConfType.phonemes, SonCBModifiedEvents[0].pct);
                }
                else
                {
                    Assert.AreEqual(0, SonCBModifiedEvents.Count);
                }
                Assert.IsFalse(ccw.GetCheck(son));

                if (prevCF != TestTheText.blackCF)
                {
                    Assert.AreEqual(1, SonCharFormattingModifiedEvents.Count);
                    Assert.AreEqual(son, SonCharFormattingModifiedEvents[0].son);
                    Assert.AreEqual(PhonConfType.phonemes, SonCharFormattingModifiedEvents[0].pct);
                    ccw.SetChkSon(son, true);
                    Assert.AreEqual(TestTheText.blackCF, ccw.GetCF(son));
                    ccw.SetChkSon(son, false);
                }
                else
                {
                    Assert.AreEqual(0, SonCharFormattingModifiedEvents.Count);
                }

                ResetEventCounters();
                ccw.SetCbxAndCF(son, TestTheText.fixCFs[i]);
                Assert.AreEqual(1, SonCBModifiedEvents.Count);
                Assert.AreEqual(son, SonCBModifiedEvents[0].son);
                Assert.AreEqual(PhonConfType.phonemes, SonCBModifiedEvents[0].pct);
                Assert.IsTrue(ccw.GetCheck(son));

                Assert.AreEqual(1, SonCharFormattingModifiedEvents.Count);
                Assert.AreEqual(son, SonCharFormattingModifiedEvents[0].son);
                Assert.AreEqual(PhonConfType.phonemes, SonCharFormattingModifiedEvents[0].pct);
                Assert.AreEqual(TestTheText.fixCFs[i], ccw.GetCF(son));
                i++;
            }

            ResetEventCounters();
            ccw.ClearAllCbxSons();
            Assert.AreEqual(i, SonCBModifiedEvents.Count);
            foreach (string son in ColConfWin.sonsValides)
            {
                bool found = false;
                foreach (SonConfigModifiedEventArgs a in SonCBModifiedEvents)
                {
                    if (a.son == son)
                    {
                        found = true;
                        Assert.IsFalse(ccw.GetCheck(son));
                        break;
                    }
                }
                Assert.IsTrue(found);
            }

            ResetEventCounters();
            ccw.SetAllCbxSons();
            Assert.AreEqual(i, SonCBModifiedEvents.Count);
            foreach (string son in ColConfWin.sonsValides)
            {
                bool found = false;
                foreach (SonConfigModifiedEventArgs a in SonCBModifiedEvents)
                {
                    if (a.son == son)
                    {
                        found = true;
                        Assert.IsTrue(ccw.GetCheck(son));
                        break;
                    }
                }
                Assert.IsTrue(found);
            }

            CheckConsistency(ccw);
        }