Exemplo n.º 1
0
        public void TestVersionUn()
        {
            bool resultat = Premiers.EstPremier(101);
            bool attendu  = true;

            Assert.AreEqual(attendu, resultat, "resultat incorrect");
            Assert.IsTrue(Premiers.EstPremier(101));
        }
Exemplo n.º 2
0
 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");
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 public void TestVersionTrois()
 // test pour vérifier qu'une exception est bien levée
 {
     bool resultat = Premiers.EstPremier(-1);
 }
Exemplo n.º 5
0
 public void TestVersionDeux()
 {
     Assert.IsFalse(Premiers.EstPremier(1), "resultat incorrect");
     Assert.IsFalse(Premiers.EstPremier(0), "resultat incorrect");
 }