@Test public void testFormatageDateJour() { Calendar calendrier = Calendar.getInstance(); long WEEK_IN_MILLI_SEC = 604800000l; calendrier.setTimeInMillis(new Date().getTime() - WEEK_IN_MILLI_SEC); int valeurJourSemaine = calendrier.get(Calendar.DAY_OF_WEEK); int valeurJourMois = calendrier.get(Calendar.DAY_OF_MONTH); int DAYS_IN_WEEK = 7; for (int i = 1; i <= DAYS_IN_WEEK; i++) { calendrier.set(Calendar.DAY_OF_MONTH, valeurJourMois); Date date = calendrier.getTime(); String resultat = Formatage.formatageDate(date); if (valeurJourSemaine > Calendar.DAY_OF_WEEK) { int PREMIER_JOUR = 1; valeurJourSemaine = PREMIER_JOUR; } assertEquals(Formatage.JourFormat.values()[valeurJourSemaine - 1].toString(), resultat); valeurJourSemaine++; valeurJourMois++; } }
@Test public void testRedimensionnerImage() { ImageIcon imageBar = new ImageIcon("ChatDesk/src/ca/qc/bdeb/gr1_420_P56_BB/Images/bar.png"); int tailleY = 20; int tailleX = 20; ImageIcon imageBarModifiee = Formatage.redimensionnerImage(imageBar, tailleX, tailleY); assertEquals(imageBarModifiee.getIconWidth(), tailleX); assertEquals(imageBarModifiee.getIconHeight(), tailleY); }
@Test public void testFormatageDateMinutes() { Calendar calendrier = Calendar.getInstance(); long CINQ_MIN_MILLI_SEC = 300000l; calendrier.setTimeInMillis(new Date().getTime() - CINQ_MIN_MILLI_SEC); Date date = calendrier.getTime(); String resultat = Formatage.formatageDate(date); assertEquals(resultat, "5" + Formatage.HeureFormat.MINUTE); }
@Test public void testFormatageDateHeure() { Calendar calendrier = Calendar.getInstance(); long DEUX_HEURE_MILLI_SEC = 7200000l; calendrier.setTimeInMillis(new Date().getTime() - DEUX_HEURE_MILLI_SEC); Date date = calendrier.getTime(); String resultat = Formatage.formatageDate(date); assertEquals(resultat, "2" + Formatage.HeureFormat.HEURE); }
@Test public void testFormatageDateMaintenant() { String resultat = Formatage.formatageDate(new Date()); assertEquals(resultat, "Maintenant"); }