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_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 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 TestGetForPhons() { ColConfWin ccw = conf.colors[PhonConfType.phonemes]; Dictionary <string, CharFormatting> son2CF = SetTestConfig(ccw); Assert.AreEqual(ccw.GetCF("a"), ccw.GetCF(Phonemes.a)); Assert.AreEqual(ccw.GetCF("q"), ccw.GetCF(Phonemes.q)); Assert.AreEqual(ccw.GetCF("q_caduc"), ccw.GetCF(Phonemes.q_caduc)); Assert.AreEqual(ccw.GetCF("i"), ccw.GetCF(Phonemes.i)); Assert.AreEqual(ccw.GetCF("o"), ccw.GetCF(Phonemes.o)); Assert.AreEqual(ccw.GetCF("o"), ccw.GetCF(Phonemes.o_comp)); Assert.AreEqual(ccw.GetCF("u"), ccw.GetCF(Phonemes.u)); Assert.AreEqual(ccw.GetCF("y"), ccw.GetCF(Phonemes.y)); Assert.AreEqual(ccw.GetCF("é"), ccw.GetCF(Phonemes.e)); Assert.AreEqual(ccw.GetCF("è"), ccw.GetCF(Phonemes.E)); Assert.AreEqual(ccw.GetCF("è"), ccw.GetCF(Phonemes.E_comp)); Assert.AreEqual(ccw.GetCF("é"), ccw.GetCF(Phonemes.e_comp)); Assert.AreEqual(ccw.GetCF("5"), ccw.GetCF(Phonemes.e_tilda)); Assert.AreEqual(ccw.GetCF("an"), ccw.GetCF(Phonemes.a_tilda)); Assert.AreEqual(ccw.GetCF("on"), ccw.GetCF(Phonemes.o_tilda)); Assert.AreEqual(ccw.GetCF("1"), ccw.GetCF(Phonemes.x_tilda)); Assert.AreEqual(ccw.GetCF("2"), ccw.GetCF(Phonemes.x2)); Assert.AreEqual(ccw.GetCF("oi"), ccw.GetCF(Phonemes.oi)); Assert.AreEqual(ccw.GetCF("oin"), ccw.GetCF(Phonemes.w_e_tilda)); Assert.AreEqual(ccw.GetCF("w"), ccw.GetCF(Phonemes.w)); Assert.AreEqual(ccw.GetCF("j"), ccw.GetCF(Phonemes.j)); Assert.AreEqual(ccw.GetCF("ng"), ccw.GetCF(Phonemes.J)); Assert.AreEqual(ccw.GetCF("ij"), ccw.GetCF(Phonemes.i_j)); Assert.AreEqual(ccw.GetCF("gn"), ccw.GetCF(Phonemes.N)); Assert.AreEqual(ccw.GetCF("p"), ccw.GetCF(Phonemes.p)); Assert.AreEqual(ccw.GetCF("b"), ccw.GetCF(Phonemes.b)); Assert.AreEqual(ccw.GetCF("t"), ccw.GetCF(Phonemes.t)); Assert.AreEqual(ccw.GetCF("d"), ccw.GetCF(Phonemes.d)); Assert.AreEqual(ccw.GetCF("k"), ccw.GetCF(Phonemes.k)); Assert.AreEqual(ccw.GetCF("g"), ccw.GetCF(Phonemes.g)); Assert.AreEqual(ccw.GetCF("f"), ccw.GetCF(Phonemes.f)); Assert.AreEqual(ccw.GetCF("v"), ccw.GetCF(Phonemes.v)); Assert.AreEqual(ccw.GetCF("s"), ccw.GetCF(Phonemes.s)); Assert.AreEqual(ccw.GetCF("z"), ccw.GetCF(Phonemes.z)); Assert.AreEqual(ccw.GetCF("ch"), ccw.GetCF(Phonemes.S)); Assert.AreEqual(ccw.GetCF("ge"), ccw.GetCF(Phonemes.Z)); Assert.AreEqual(ccw.GetCF("m"), ccw.GetCF(Phonemes.m)); Assert.AreEqual(ccw.GetCF("n"), ccw.GetCF(Phonemes.n)); Assert.AreEqual(ccw.GetCF("l"), ccw.GetCF(Phonemes.l)); Assert.AreEqual(ccw.GetCF("r"), ccw.GetCF(Phonemes.R)); Assert.AreEqual(ccw.GetCF("f"), ccw.GetCF(Phonemes.f_ph)); Assert.AreEqual(ccw.GetCF("k"), ccw.GetCF(Phonemes.k_qu)); Assert.AreEqual(ccw.GetCF("g"), ccw.GetCF(Phonemes.g_u)); Assert.AreEqual(ccw.GetCF("s"), ccw.GetCF(Phonemes.s_c)); Assert.AreEqual(ccw.GetCF("s"), ccw.GetCF(Phonemes.s_t)); Assert.AreEqual(ccw.GetCF("s"), ccw.GetCF(Phonemes.s_x)); Assert.AreEqual(ccw.GetCF("z"), ccw.GetCF(Phonemes.z_s)); Assert.AreEqual(ccw.GetCF("ks"), ccw.GetCF(Phonemes.ks)); Assert.AreEqual(ccw.GetCF("gz"), ccw.GetCF(Phonemes.gz)); Assert.AreEqual(ccw.GetCF("_muet"), ccw.GetCF(Phonemes.verb_3p)); Assert.AreEqual(ccw.GetCF("_muet"), ccw.GetCF(Phonemes._muet)); Assert.AreEqual(ccw.GetCF("ill"), ccw.GetCF(Phonemes.j_ill)); Assert.AreEqual(ccw.GetCF("ill"), ccw.GetCF(Phonemes.i_j_ill)); Assert.AreEqual(ccw.GetCF("j"), ccw.GetCF(Phonemes.ji)); Assert.AreEqual(ccw.GetCF("47"), ccw.GetCF(Phonemes.chiffre)); }
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); }