예제 #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 override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case "sonCF":
                if (prevCF != null)
                {
                    ccw.SetCFSon(son, prevCF);
                }
                break;

            case "sonCB":
                ccw.SetChkSon(son, prevCB);
                break;

            case "ill":
                ccw.IllRuleToUse = prevIllRule;
                break;

            case "defBeh":
                ccw.SetDefaultBehaviourTo(prevDefBeh);
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
예제 #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 TestEvents3()
        {
            ColConfWin ccw = conf.colors[PhonConfType.phonemes];
            int        i   = 0;

            foreach (string son in ColConfWin.sonsValides)
            {
                ccw.SetChkSon(son, false);
                ResetEventCounters();
                ccw.SetChkSon(son, true);
                Assert.AreEqual(1, SonCBModifiedEvents.Count);
                Assert.AreEqual(son, SonCBModifiedEvents[0].son);
                Assert.AreEqual(PhonConfType.phonemes, SonCBModifiedEvents[0].pct);
                Assert.IsTrue(ccw.GetCheck(son));

                ResetEventCounters();
                ccw.SetChkSon(son, true);
                Assert.AreEqual(0, SonCBModifiedEvents.Count);
                Assert.IsTrue(ccw.GetCheck(son));

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

                ResetEventCounters();
                ccw.SetCFSon(son, TestTheText.fixCFs[i]);
                Assert.AreEqual(0, SonCharFormattingModifiedEvents.Count);
                Assert.AreEqual(TestTheText.fixCFs[i], ccw.GetCF(son));

                i++;
            }

            CheckConsistency(ccw);
        }
예제 #5
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);
        }