@MediumTest public void test_checkIsNewNews() { Calendar c = Calendar.getInstance(); int day = c.get(Calendar.DAY_OF_MONTH); int month = c.get(Calendar.MONTH) + 1; int year = c.get(Calendar.YEAR); NewsModel newsModel = new NewsModel(); newsModel.setDatetime(year + "-" + month + "-" + day + " 12:00:00"); assertTrue(newsModel.isNew()); newsModel.setDatetime(year + "-" + month + "-" + (day + 1) + " 12:00:00"); assertFalse(newsModel.isNew()); }
@MediumTest public void test_formatToYesterdayOrToday_ForYesterday() { Calendar c = Calendar.getInstance(); int day = c.get(Calendar.DAY_OF_MONTH); int month = c.get(Calendar.MONTH) + 1; int year = c.get(Calendar.YEAR); NewsModel newsModel = new NewsModel(); newsModel.setDatetime(year + "-" + month + "-" + (day - 1) + " 12:00:00"); assertEquals(" دیروز ", newsModel.formatToYesterdayOrToday()); }