Commit 6db9bd7b authored by Robert Hitt's avatar Robert Hitt

Fixed some logic errors

-Specifically related to facilities open past midnight.
-Also added some more tests
parent 339ae744
Pipeline #881 passed with stages
in 9 minutes and 58 seconds
......@@ -206,6 +206,11 @@ public class MainPresenter {
return "Open 24/7";
}
if(getCurrentEndTime(openTimesList, currentDay).equals("23:59:59") &&
getCurrentStartTime(openTimesList, (currentDay+1)%7).equals("00:00:00")) {
currentDay++;
}
String closingTime = getCurrentEndTime(openTimesList, currentDay);
closingTime = FacilityPresenter.parseTo12HourTime(closingTime);
durationMessage = "Closes at " + closingTime;
......
......@@ -55,6 +55,22 @@ public class MainPresenterUnitTest {
assertTrue(mPresenter.getOpenStatus(mFacility, now));
}
@Test
public void testFacilityIsOpenPastMidnight() {
// Set date
now.set(2017, 0, 12, 1, 0); // Thursday, 1/12/2017, 02:00:00
// Add more open times
OpenTimes o3 = new OpenTimes(2, 2, "13:00:00", "23:59:59"); // Wednesday 13:00-midnight
OpenTimes o4 = new OpenTimes(3, 3, "13:00:00", "23:59:59"); // Thursday 13:00-midnight
OpenTimes o5 = new OpenTimes(3, 3, "00:00:00", "02:00:00"); // Thursday 00:00-02:00
mFacility.getMainSchedule().getOpenTimesList().add(o3);
mFacility.getMainSchedule().getOpenTimesList().add(o4);
mFacility.getMainSchedule().getOpenTimesList().add(o5);
assertTrue(mPresenter.getOpenStatus(mFacility, now));
}
@Test
public void testFacilityIsClosed() {
// Set date
......@@ -99,6 +115,25 @@ public class MainPresenterUnitTest {
assertEquals("Closes at 6:00 PM", statusDuration);
}
@Test
public void testFacilityMessageClosesPastMidnight() {
// Set date
now.set(2017, 0, 12, 14, 0); // Thursday, 1/12/2017, 14:00:00
mFacility.setOpen(true);
// Add more open times
OpenTimes o3 = new OpenTimes(2, 2, "13:00:00", "23:59:59"); // Wednesday 13:00-midnight
OpenTimes o4 = new OpenTimes(3, 3, "13:00:00", "23:59:59"); // Thursday 13:00-midnight
OpenTimes o5 = new OpenTimes(3, 3, "00:00:00", "02:00:00"); // Thursday 00:00-02:00
mFacility.getMainSchedule().getOpenTimesList().add(o3);
mFacility.getMainSchedule().getOpenTimesList().add(o4);
mFacility.getMainSchedule().getOpenTimesList().add(o5);
String statusDuration = mPresenter.getStatusDuration(mFacility, now);
assertEquals("Closes at 2:00 AM", statusDuration);
}
@Test
public void testFacilityMessageNoSchedule() {
// Set date
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment