Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-android
Commits
6db9bd7b
Commit
6db9bd7b
authored
Feb 13, 2017
by
Robert Hitt
Browse files
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
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/srct/whatsopen/presenters/MainPresenter.java
View file @
6db9bd7b
...
...
@@ -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
;
...
...
app/src/test/java/srct/whatsopen/MainPresenterUnitTest.java
View file @
6db9bd7b
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment