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)); }
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)); } }
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); }
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("é")); }
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); }