public void TestVersionUn() { bool resultat = Premiers.EstPremier(101); bool attendu = true; Assert.AreEqual(attendu, resultat, "resultat incorrect"); Assert.IsTrue(Premiers.EstPremier(101)); }
public void TestVersionCinq() // encore une autre façon de tester { try { bool resultat = Premiers.EstPremier(-5); Assert.Fail("Pas d'exception lancée"); } catch (Exception ex) { // on vérifie l'exception StringAssert.Contains(ex.Message, "entier non naturel"); } }
public void TestVersionQuatre() // test pour vérifier qu'aucune exception est levée // si l'entier est naturel { try { bool resultat = Premiers.EstPremier(5); Assert.Fail(); } catch (Exception ex) { Assert.IsTrue(ex is AssertFailedException); } }
public void TestVersionTrois() // test pour vérifier qu'une exception est bien levée { bool resultat = Premiers.EstPremier(-1); }
public void TestVersionDeux() { Assert.IsFalse(Premiers.EstPremier(1), "resultat incorrect"); Assert.IsFalse(Premiers.EstPremier(0), "resultat incorrect"); }