Exemplo n.º 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));
        }
Exemplo n.º 2
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);
        }