This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import random | |
import time | |
from multiprocessing import Process | |
import tqdm | |
ITERATIONS = 10 | |
PHILOSOPHERS_CNT = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TicketMachineTest { | |
private val printerMock = mockk<Printer>(relaxed = true) | |
@Test | |
fun `given ticket machine when adult ticket selected and paid then ticket printed`() { | |
val ticketMachine = DaggerTestTicketMachineComponent.factory() | |
.create(printerMock) | |
.ticketMachine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Component(modules = [ | |
TicketMachineModule::class, | |
]) | |
interface TestTicketMachineComponent { | |
@Component.Factory | |
interface Factory { | |
fun create( | |
@BindsInstance printer: Printer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TicketMachineTest { | |
private val printerMock = mockk<Printer>(relaxed = true) | |
@Test | |
fun `given ticket machine when adult ticket selected and paid then ticket printed`() { | |
val ticketMachine = DaggerTestTicketMachineComponent.builder() | |
.testPrinterModule(TestPrinterModule(printerMock)) | |
.build() | |
.ticketMachine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
class TestPrinterModule(private val printer: Printer) { | |
@Provides | |
@Singleton | |
fun printer() = printer | |
} | |
@Singleton | |
@Component(modules = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TicketMachineTest { | |
private val printerMock = mockk<Printer>(relaxed = true) | |
@Test | |
fun `given ticket machine when adult ticket selected and paid then ticket printed`() { | |
val ticketMachine = DaggerTicketMachineComponent.builder() | |
.printerModule(TestPrinterModule(printerMock)) | |
.build() | |
.ticketMachine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestPrinterModule(private val printer: Printer) : PrinterModule() { | |
override fun printer(display: Display) = printer | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ticketMachine = DaggerTicketMachineComponent.builder() | |
.printerModule(PrinterModule()) | |
.build() | |
.ticketMachine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
open class PrinterModule { | |
@Provides | |
@Singleton | |
open fun printer(display: Display): Printer = Printer(display) | |
} | |
@Module | |
class TicketMachineModule { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ticketMachine = DaggerTicketMachineComponent.create() | |
.ticketMachine |
NewerOlder