File tree Expand file tree Collapse file tree 3 files changed +13
-12
lines changed
main/kotlin/com/mvcoding/mvp
test/kotlin/com/mvcoding/mvp Expand file tree Collapse file tree 3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change 1
1
/.idea
2
+ /build
Original file line number Diff line number Diff line change @@ -8,14 +8,14 @@ abstract class Presenter<VIEW : Presenter.View> {
8
8
private lateinit var viewSubscriptions: CompositeSubscription
9
9
private var view: View ? = null
10
10
11
- fun attach (view : VIEW ) {
11
+ infix fun attach (view : VIEW ) {
12
12
ensureViewIsNotAttached(view)
13
13
this .view = view
14
14
this .viewSubscriptions = CompositeSubscription ()
15
15
onViewAttached(view)
16
16
}
17
17
18
- fun detach (view : VIEW ) {
18
+ infix fun detach (view : VIEW ) {
19
19
ensureGivenViewIsAttached(view)
20
20
this .view = null
21
21
this .viewSubscriptions.unsubscribe()
Original file line number Diff line number Diff line change @@ -14,26 +14,26 @@ class PresenterTest {
14
14
15
15
@Test(expected = IllegalStateException ::class )
16
16
fun throwsIllegalStateExceptionWhenViewIsAlreadyAttached () {
17
- presenter. attach( view)
18
- presenter. attach( view)
17
+ presenter attach view
18
+ presenter attach view
19
19
}
20
20
21
21
@Test(expected = IllegalStateException ::class )
22
22
fun throwsIllegalStateExceptionWhenViewWasNotAttached () {
23
- presenter. detach( view)
23
+ presenter detach view
24
24
}
25
25
26
26
@Test(expected = IllegalStateException ::class )
27
27
fun throwsIllegalStateExceptionWhenViewWasAlreadyDetached () {
28
- presenter. attach( view)
29
- presenter. detach( view)
30
- presenter. detach( view)
28
+ presenter attach view
29
+ presenter detach view
30
+ presenter detach view
31
31
}
32
32
33
33
@Test(expected = IllegalStateException ::class )
34
34
fun throwsIllegalStateExceptionWhenTryingToDetachDifferentView () {
35
- presenter. attach( view)
36
- presenter. detach( mock<Presenter .View >() )
35
+ presenter attach view
36
+ presenter detach mock<Presenter .View >()
37
37
}
38
38
39
39
@Test
@@ -44,8 +44,8 @@ class PresenterTest {
44
44
val events = just(Unit ).doOnSubscribe { isSubscribed = true }.doOnUnsubscribe { isSubscribed = false }
45
45
whenever(view.events()).thenReturn(events)
46
46
47
- presenter. attach( view)
48
- presenter. detach( view)
47
+ presenter attach view
48
+ presenter detach view
49
49
50
50
assertFalse { isSubscribed }
51
51
}
You can’t perform that action at this time.
0 commit comments