♻️ Refactor test
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 28 Jul 2019 14:09:39 +0000 (16:09 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 28 Jul 2019 19:03:46 +0000 (21:03 +0200)
src/test/kotlin/net/pterodactylus/sone/core/CoreTest.kt

index f595cc0..1b2b363 100644 (file)
@@ -138,21 +138,18 @@ class CoreTest {
 
        @Test
        fun `core starts with debug set to false`() {
-               val configuration = mock<Configuration>()
-               val freenetInterface = mock<FreenetInterface>()
-               val identityManager = mock<IdentityManager>()
-               val soneDownloader = mock<SoneDownloader>()
-               val imageInserter = mock<ImageInserter>()
-               val updateChecker = mock<UpdateChecker>()
-               val webOfTrustUpdater = mock<WebOfTrustUpdater>()
-               val eventBus = mock<EventBus>()
-               val database = mock<Database>()
-               val core = Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database)
+               val core = createCore()
                assertThat(core.debug, equalTo(false))
        }
 
        @Test
        fun `debug flag can be set`() {
+               val core = createCore()
+               core.setDebug()
+               assertThat(core.debug, equalTo(true))
+       }
+
+       private fun createCore(): Core {
                val configuration = mock<Configuration>()
                val freenetInterface = mock<FreenetInterface>()
                val identityManager = mock<IdentityManager>()
@@ -162,9 +159,7 @@ class CoreTest {
                val webOfTrustUpdater = mock<WebOfTrustUpdater>()
                val eventBus = mock<EventBus>()
                val database = mock<Database>()
-               val core = Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database)
-               core.setDebug()
-               assertThat(core.debug, equalTo(true))
+               return Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database)
        }
 
 }