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 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 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 TestDefaultMuettes() { ColConfWin ccw = conf.colors[PhonConfType.muettes]; Assert.AreEqual(cfMUET, ccw.GetCF("_muet")); HashSet <string> sonsMuets = new HashSet <string>() { "_muet" }; HashSet <string> tousLesSons = new HashSet <string>(ColConfWin.sonsValides); tousLesSons.ExceptWith(sonsMuets); HashSet <string> sonsNonMuets = tousLesSons; foreach (string son in sonsMuets) { Assert.IsTrue(ccw.GetCheck(son)); } foreach (string son in sonsNonMuets) { Assert.IsFalse(ccw.GetCheck(son)); } CheckConsistency(ccw); }
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); }
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); }
public void TestePredefCols() { ColConfWin ccw = conf.colors[PhonConfType.phonemes]; Assert.AreEqual(cNoir, ColConfWin.predefinedColors[(int)PredefCol.black]); Assert.AreEqual(cJaune, ColConfWin.predefinedColors[(int)PredefCol.darkYellow]); Assert.AreEqual(cOrange, ColConfWin.predefinedColors[(int)PredefCol.orange]); Assert.AreEqual(cVertSapin, ColConfWin.predefinedColors[(int)PredefCol.darkGreen]); Assert.AreEqual(cViolet, ColConfWin.predefinedColors[(int)PredefCol.violet]); Assert.AreEqual(cBleuFoncé, ColConfWin.predefinedColors[(int)PredefCol.darkBlue]); Assert.AreEqual(cRouge, ColConfWin.predefinedColors[(int)PredefCol.red]); Assert.AreEqual(cMarron, ColConfWin.predefinedColors[(int)PredefCol.brown]); Assert.AreEqual(cBleu, ColConfWin.predefinedColors[(int)PredefCol.blue]); Assert.AreEqual(cTurquoise, ColConfWin.predefinedColors[(int)PredefCol.turquoise]); Assert.AreEqual(cGris, ColConfWin.predefinedColors[(int)PredefCol.grey]); Assert.AreEqual(cRose, ColConfWin.predefinedColors[(int)PredefCol.pink]); Assert.AreEqual(cVertGren, ColConfWin.predefinedColors[(int)PredefCol.frogGreen]); Assert.AreEqual(cGrisUn, ColConfWin.predefinedColors[(int)PredefCol.cerasUn]); Assert.AreEqual(cGrisNeutre, ColConfWin.predefinedColors[(int)PredefCol.neutral]); Assert.AreEqual(cBleuPur, ColConfWin.predefinedColors[(int)PredefCol.pureBlue]); Assert.AreEqual(cBleuClair, ColConfWin.predefinedColors[(int)PredefCol.lightBlue]); Assert.AreEqual(cRougeFonce, ColConfWin.predefinedColors[(int)PredefCol.darkRed]); Assert.AreEqual(cBlanc, ColConfWin.predefinedColors[(int)PredefCol.white]); // CharFormatting Assert.AreEqual(cfBlack, ColConfWin.coloredCF[(int)PredefCol.black]); Assert.AreEqual(cfO, ColConfWin.coloredCF[(int)PredefCol.darkYellow]); Assert.AreEqual(cfAN, ColConfWin.coloredCF[(int)PredefCol.orange]); Assert.AreEqual(cf5, ColConfWin.coloredCF[(int)PredefCol.darkGreen]); Assert.AreEqual(cfE, ColConfWin.coloredCF[(int)PredefCol.violet]); Assert.AreEqual(cfe, ColConfWin.coloredCF[(int)PredefCol.darkBlue]); Assert.AreEqual(cfu, ColConfWin.coloredCF[(int)PredefCol.red]); Assert.AreEqual(cfON, ColConfWin.coloredCF[(int)PredefCol.brown]); Assert.AreEqual(cf2, ColConfWin.coloredCF[(int)PredefCol.blue]); Assert.AreEqual(cfOIN, ColConfWin.coloredCF[(int)PredefCol.turquoise]); Assert.AreEqual(cfMUET, ColConfWin.coloredCF[(int)PredefCol.grey]); Assert.AreEqual(cfeRose, ColConfWin.coloredCF[(int)PredefCol.pink]); Assert.AreEqual(cfVGrenou, ColConfWin.coloredCF[(int)PredefCol.frogGreen]); Assert.AreEqual(cfGrisUn, ColConfWin.coloredCF[(int)PredefCol.cerasUn]); Assert.AreEqual(cfNeutre, ColConfWin.coloredCF[(int)PredefCol.neutral]); Assert.AreEqual(cfBLEU, ColConfWin.coloredCF[(int)PredefCol.pureBlue]); Assert.AreEqual(cfBLEUCLAIR, ColConfWin.coloredCF[(int)PredefCol.lightBlue]); Assert.AreEqual(cfROUGEF, ColConfWin.coloredCF[(int)PredefCol.darkRed]); Assert.AreEqual(cfBLANC, ColConfWin.coloredCF[(int)PredefCol.white]); // La seule chose qui compte pour les couleurs CERAS est qu'elles soient attribuées // correctement aux sons. // configuration par défaut: CERAS rosé. HashSet <string> cerasSons = new HashSet <string>() { "oi", "o", "an", "5", "è", "u", "on", "2", "oin", "_muet", "é", "ill", "1" }; HashSet <string> tousLesSons = new HashSet <string>(ColConfWin.sonsValides); tousLesSons.ExceptWith(cerasSons); HashSet <string> sonsNonCeras = tousLesSons; Assert.IsTrue(cerasSons.IsSubsetOf(ColConfWin.sonsValides)); Assert.AreEqual(cfOI, ccw.GetCF("oi")); Assert.AreEqual(cfO, ccw.GetCF("o")); Assert.AreEqual(cfAN, ccw.GetCF("an")); Assert.AreEqual(cf5, ccw.GetCF("5")); Assert.AreEqual(cfE, ccw.GetCF("è")); Assert.AreEqual(cfu, ccw.GetCF("u")); Assert.AreEqual(cfON, ccw.GetCF("on")); Assert.AreEqual(cf2, ccw.GetCF("2")); Assert.AreEqual(cfOIN, ccw.GetCF("oin")); Assert.AreEqual(cfMUET, ccw.GetCF("_muet")); Assert.AreEqual(cfeRose, ccw.GetCF("é")); Assert.AreEqual(cfILL, ccw.GetCF("ill")); Assert.AreEqual(cf1, ccw.GetCF("1")); foreach (string son in cerasSons) { Assert.IsTrue(ccw.GetCheck(son)); } foreach (string son in sonsNonCeras) { Assert.IsFalse(ccw.GetCheck(son)); } ResetEventCounters(); ccw.SetCeras(); Assert.AreEqual(2, SonCharFormattingModifiedEvents.Count); // é et ill Assert.AreEqual(1, SonCBModifiedEvents.Count); // ill Assert.AreEqual("ill", SonCBModifiedEvents[0].son); Assert.AreEqual(cfOI, ccw.GetCF("oi")); Assert.AreEqual(cfO, ccw.GetCF("o")); Assert.AreEqual(cfAN, ccw.GetCF("an")); Assert.AreEqual(cf5, ccw.GetCF("5")); Assert.AreEqual(cfE, ccw.GetCF("è")); Assert.AreEqual(cfe, ccw.GetCF("é")); Assert.AreEqual(cfu, ccw.GetCF("u")); Assert.AreEqual(cfON, ccw.GetCF("on")); Assert.AreEqual(cf2, ccw.GetCF("2")); Assert.AreEqual(cfOIN, ccw.GetCF("oin")); Assert.AreEqual(cfMUET, ccw.GetCF("_muet")); Assert.AreEqual(cf1, ccw.GetCF("1")); cerasSons.Remove("ill"); sonsNonCeras.Add("ill"); foreach (string son in cerasSons) { Assert.IsTrue(ccw.GetCheck(son)); } foreach (string son in sonsNonCeras) { Assert.IsFalse(ccw.GetCheck(son)); } CheckConsistency(ccw); }
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); }