public void TestMethod1() { // Effacer tous les formatages SylConfig sC = conf.sylConf; for (int i = SylConfig.NrButtons - 1; i >= 0; i--) { if (sC.ButtonIsLastActive(i)) { sC.ClearButton(i); Assert.IsTrue(sylButModNr.Contains(i)); if (i < SylConfig.NrButtons - 2) { Assert.IsTrue(sylButModNr.Contains(i + 1)); } } else { Assert.ThrowsException <ArgumentException>(() => sC.ClearButton(i)); } CheckConsistency(sC); ResetEventCounters(); } Assert.IsTrue(sC.ButtonIsActivableOne(0)); // conf.sylConf.SylButtonModified(0, TestTheText.blueCF); Assert.ThrowsException <ArgumentException> (() => sC.SetSylButtonCF(1, TestTheText.redCF)); CheckConsistency(sC); }
public void TestMethod3() { TestMethod2(); SylConfig sC = conf.sylConf; // on sait que tous les boutons ont un CF for (int i = 0; i < SylConfig.NrButtons - 1; i++) { Assert.ThrowsException <ArgumentException>(() => sC.ClearButton(i)); CheckConsistency(sC); } }
public void TestMethod6() { // Effacer tous les formatages SylConfig sC = conf.sylConf; for (int i = SylConfig.NrButtons - 1; i >= 0; i--) { if (sC.ButtonIsLastActive(i)) { sC.ClearButton(i); } } ResetEventCounters(); sC.SetSylButtonCF("0", TestTheText.blueCF); Assert.IsTrue(sylButModNr.Contains(0)); Assert.IsTrue(sylButModNr.Contains(1)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, conf); ResetEventCounters(); sC.SetSylButtonCF("1", TestTheText.redCF); Assert.IsTrue(sylButModNr.Contains(1)); Assert.IsTrue(sylButModNr.Contains(2)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, conf); ResetEventCounters(); sC.SetSylButtonCF("2", TestTheText.fixCFs[2]); Assert.IsTrue(sylButModNr.Contains(2)); Assert.IsTrue(sylButModNr.Contains(3)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], conf); ResetEventCounters(); sC.SetSylButtonCF("3", TestTheText.fixCFs[3]); Assert.IsTrue(sylButModNr.Contains(3)); Assert.IsTrue(sylButModNr.Contains(4)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[3], conf); ResetEventCounters(); sC.SetSylButtonCF("4", TestTheText.fixCFs[4]); Assert.IsTrue(sylButModNr.Contains(4)); Assert.IsTrue(sylButModNr.Contains(5)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[3], TestTheText.fixCFs[4], conf); ResetEventCounters(); sC.SetSylButtonCF("5", TestTheText.fixCFs[5]); Assert.IsTrue(sylButModNr.Contains(5)); Assert.IsTrue(sylButModNr.Count == 1); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[3], TestTheText.fixCFs[4], TestTheText.fixCFs[5], conf); ResetEventCounters(); sC.SetSylButtonCF("4", TestTheText.fixCFs[7]); Assert.IsTrue(sylButModNr.Contains(4)); Assert.IsTrue(sylButModNr.Count == 1); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[3], TestTheText.fixCFs[7], TestTheText.fixCFs[5], conf); sC.Reset(); Assert.IsTrue(sC.DoubleConsStd); Assert.AreEqual(SylConfig.Mode.ecrit, sC.mode); Assert.IsTrue(sC.marquerMuettes); Assert.IsTrue(sC.chercherDierese); Assert.AreEqual(0, sC.nbrPieds); Assert.AreEqual(ColConfWinTest.cfBLEU, sC.GetSylButtonConfFor(0).cf); Assert.AreEqual(ColConfWinTest.cfu, sC.GetSylButtonConfFor(1).cf); Assert.IsTrue(sC.ButtonIsLastActive(1)); Assert.IsTrue(sC.ButtonIsActivableOne(2)); Assert.IsTrue(sC.GetSylButtonConfFor(0).buttonClickable); Assert.IsTrue(sC.GetSylButtonConfFor(1).buttonClickable); Assert.IsTrue(sC.GetSylButtonConfFor(2).buttonClickable); Assert.IsFalse(sC.GetSylButtonConfFor(3).buttonClickable); }
public void TestMethod2() { // Effacer tous les formatages SylConfig sC = conf.sylConf; for (int i = SylConfig.NrButtons - 1; i >= 0; i--) { if (sC.ButtonIsLastActive(i)) { sC.ClearButton(i); } } ResetEventCounters(); sC.SetSylButtonCF(0, TestTheText.blueCF); Assert.IsTrue(sylButModNr.Contains(0)); Assert.IsTrue(sylButModNr.Contains(1)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, conf); ResetEventCounters(); sC.SetSylButtonCF(1, TestTheText.redCF); Assert.IsTrue(sylButModNr.Contains(1)); Assert.IsTrue(sylButModNr.Contains(2)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, conf); ResetEventCounters(); sC.SetSylButtonCF(2, TestTheText.fixCFs[2]); Assert.IsTrue(sylButModNr.Contains(2)); Assert.IsTrue(sylButModNr.Contains(3)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], conf); ResetEventCounters(); sC.SetSylButtonCF(3, TestTheText.fixCFs[3]); Assert.IsTrue(sylButModNr.Contains(3)); Assert.IsTrue(sylButModNr.Contains(4)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[3], conf); ResetEventCounters(); sC.SetSylButtonCF(4, TestTheText.fixCFs[4]); Assert.IsTrue(sylButModNr.Contains(4)); Assert.IsTrue(sylButModNr.Contains(5)); Assert.IsTrue(sylButModNr.Count == 2); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[3], TestTheText.fixCFs[4], conf); ResetEventCounters(); sC.SetSylButtonCF(5, TestTheText.fixCFs[5]); Assert.IsTrue(sylButModNr.Contains(5)); Assert.IsTrue(sylButModNr.Count == 1); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[3], TestTheText.fixCFs[4], TestTheText.fixCFs[5], conf); ResetEventCounters(); sC.SetSylButtonCF(3, TestTheText.fixCFs[7]); Assert.IsTrue(sylButModNr.Contains(3)); Assert.IsTrue(sylButModNr.Count == 1); CheckConsistency(sC); CheckAlernateCF(TestTheText.blueCF, TestTheText.redCF, TestTheText.fixCFs[2], TestTheText.fixCFs[7], TestTheText.fixCFs[4], TestTheText.fixCFs[5], conf); }
public void TestMethod4() { // Il faut vérifier que le flag markAsBlack a bien l'effet voulu. PBDQConfig pC = conf.pBDQ; TestTheText ttt = new TestTheText(text1); ttt.AssertColor(12, TestTheText.black); // Tout marquer avec un seul CF SylConfig sC = conf.sylConf; for (int i = SylConfig.NrButtons - 1; i >= 0; i--) { if (sC.ButtonIsLastActive(i)) { sC.ClearButton(i); } } conf.sylConf.SetSylButtonCF(0, TestTheText.fixCFs[7]); ttt.MarkWords(conf); ttt.AssertNotColor(12, TestTheText.black); ttt.AssertBold(12, true); CharFormatting cf12 = ttt.GetCF(12); pC.SetMarkAsBlackTo(false); Assert.IsTrue(pC.UpdateLetter(0, 'M', TestTheText.fixCFs[0])); Assert.IsTrue(pC.UpdateLetter(1, 'P', TestTheText.fixCFs[1])); Assert.IsTrue(pC.UpdateLetter(2, 'e', TestTheText.fixCFs[2])); Assert.IsTrue(pC.UpdateLetter(3, 'h', TestTheText.fixCFs[3])); Assert.IsTrue(pC.UpdateLetter(4, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3])); Assert.IsTrue(pC.UpdateLetter(5, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3])); Assert.IsTrue(pC.UpdateLetter(6, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3])); Assert.IsTrue(pC.UpdateLetter(7, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3])); Assert.IsFalse(pC.UpdateLetter(3, 'M', TestTheText.fixCFs[0])); Assert.IsFalse(pC.UpdateLetter(4, 'M', TestTheText.fixCFs[0])); Assert.IsFalse(pC.UpdateLetter(5, 'P', TestTheText.fixCFs[0])); Assert.IsFalse(pC.UpdateLetter(6, 'e', TestTheText.fixCFs[0])); Assert.IsFalse(pC.UpdateLetter(7, 'h', TestTheText.fixCFs[0])); Assert.IsFalse(pC.UpdateLetter(1, 'M', TestTheText.fixCFs[0])); Assert.AreEqual('M', pC.GetLetterForButtonNr(0)); Assert.AreEqual('P', pC.GetLetterForButtonNr(1)); Assert.AreEqual('e', pC.GetLetterForButtonNr(2)); Assert.AreEqual('h', pC.GetLetterForButtonNr(3)); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(4)); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(5)); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(6)); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(7)); pC.SetMarkAsBlackTo(false); Assert.AreEqual(pC.GetCfForPBDQLetter( PBDQConfig.inactiveLetter), CharFormatting.NeutralCF); pC.SetMarkAsBlackTo(true); Assert.AreEqual(pC.GetCfForPBDQLetter( PBDQConfig.inactiveLetter), TestTheText.blackCF); Assert.IsTrue(pC.UpdateLetter(4, 'x', TestTheText.fixCFs[4])); Assert.IsTrue(pC.UpdateLetter(5, 'y', TestTheText.fixCFs[5])); Assert.IsTrue(pC.UpdateLetter(6, 'z', TestTheText.fixCFs[6])); Assert.IsTrue(pC.UpdateLetter(7, '§', TestTheText.fixCFs[7])); CheckConsistency(pC); pC.SetMarkAsBlackTo(false); ttt.MarkLetters(conf); int index = ttt.S.IndexOf("Monsieur"); ttt.AssertColor(index, TestTheText.fixCols[0]); ttt.AssertColor(index + 5, TestTheText.fixCols[2]); index = ttt.S.IndexOf("Poiret"); ttt.AssertColor(index, TestTheText.fixCols[1]); index = ttt.S.IndexOf("cachait"); ttt.AssertColor(index + 3, TestTheText.fixCols[3]); ttt.AssertNotColor(12, TestTheText.black); ttt.AssertCF(12, cf12); ttt.AssertBold(12, true); CheckConsistency(pC); pC.SetMarkAsBlackTo(true); ttt.MarkLetters(conf); index = ttt.S.IndexOf("Monsieur"); ttt.AssertColor(index, TestTheText.fixCols[0]); ttt.AssertColor(index + 5, TestTheText.fixCols[2]); index = ttt.S.IndexOf("Poiret"); ttt.AssertColor(index, TestTheText.fixCols[1]); index = ttt.S.IndexOf("cachait"); ttt.AssertColor(index + 3, TestTheText.fixCols[3]); ttt.AssertColor(12, TestTheText.black); ttt.AssertBold(12, true); pC.Reset(); Assert.IsFalse(pC.markAsBlack); Assert.AreEqual(ColConfWinTest.cf5, pC.GetCfForPBDQLetter('p')); Assert.AreEqual(ColConfWinTest.cfu, pC.GetCfForPBDQLetter('b')); Assert.AreEqual(ColConfWinTest.cfBLEU, pC.GetCfForPBDQLetter('d')); Assert.AreEqual(ColConfWinTest.cfON, pC.GetCfForPBDQLetter('q')); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(4)); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(5)); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(6)); Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(7)); }