-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathObserverTest.kt
25 lines (22 loc) · 936 Bytes
/
ObserverTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package org.vld.sdp.behavioral
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.mockito.Mockito.* // ktlint-disable no-wildcard-imports
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ObserverTest {
@Test
@DisplayName("Given an auctioneer and a set of bidders. When change bid. Then notify all bidders with the new bid")
fun givenAuctioneerAndSetOfBidders_whenChangeBid_thenNotifyAllBiddersWithTheNewBid() {
// Given
val actioneer: AuctioneerSubject = Auctioneer()
val mockedBidder1: BidObserver = mock(Bidder::class.java)
val mockedBidder2: BidObserver = mock(Bidder::class.java)
actioneer.register(mockedBidder1, mockedBidder2)
// When
actioneer.notifyNewBid(1)
// Then
verify(mockedBidder1).updateBid(0, 1)
verify(mockedBidder2).updateBid(0, 1)
}
}