From da2885905a3be5910922d2f792639195a4edd018 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Thu, 24 Oct 2019 01:16:36 +0900 Subject: [PATCH] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../be/zvz/kotlininside/KotlinInsideTest.kt | 83 +++++++++++++++++-- 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/src/test/kotlin/be/zvz/kotlininside/KotlinInsideTest.kt b/src/test/kotlin/be/zvz/kotlininside/KotlinInsideTest.kt index ea2c5f9c..5b0d3b18 100644 --- a/src/test/kotlin/be/zvz/kotlininside/KotlinInsideTest.kt +++ b/src/test/kotlin/be/zvz/kotlininside/KotlinInsideTest.kt @@ -3,26 +3,95 @@ */ package be.zvz.kotlininside -import be.zvz.kotlininside.api.article.ArticleList +import be.zvz.kotlininside.api.article.* +import be.zvz.kotlininside.api.type.Article +import be.zvz.kotlininside.api.type.StringContent import be.zvz.kotlininside.http.DefaultHttpClient +import be.zvz.kotlininside.session.Session import be.zvz.kotlininside.session.user.Anonymous import kotlin.test.Test import kotlin.test.assertNotNull class KotlinInsideTest { - @Test fun testGetArticle() { + var articleId = 0 + + @Test fun initKotlinInside() { KotlinInside.createInstance( Anonymous("ㅇㅇ", "1234"), DefaultHttpClient(true) ) + } + + @Test fun testArticleList() { + val articleList = ArticleList("hit", 1) + articleList.request() - val classUnderTest = ArticleList("hit", 1) - classUnderTest.request() + val gallList = articleList.getGallList() + val gallInfo = articleList.getGallInfo() - assertNotNull(classUnderTest.getGallList()[0], "ArticleList.getGallList()[0] must not be null") + assertNotNull(gallList[0], "ArticleList.getGallList()[0] must not be null") - classUnderTest.getGallList().forEach { - println(it.subject) + println(gallInfo) + gallList.forEach { + println(it) } } + + @Test fun testArticleRead() { + val articleRead = ArticleRead("hit", 1) + articleRead.request() + + println(articleRead.getViewInfo()) + println(articleRead.getViewMain()) + } + + @Test fun testArticleWrite() { + val articleWrite = ArticleWrite( + gallId = "github", + article = Article( + subject = "KotlinInside 테스트 글입니다", + content = mutableListOf( + StringContent( + string = "글은 곧 자동으로 삭제됩니다.\n글의 비밀번호는 1234입니다." + ) + ) + ), + session = KotlinInside.getInstance().session + ) + + val writeResult = articleWrite.write() + + println(writeResult) + + if (writeResult.result) + articleId = writeResult.cause + } + + @Test fun testArticleVote() { + val articleVote = ArticleVote( + gallId = "github", + articleId = articleId, + session = KotlinInside.getInstance().session + ) + + val upvoteResult = articleVote.upvote() + + println(upvoteResult) + + val downvoteResult = articleVote.downvote() + + println(downvoteResult) + } + + @Test fun testArticleDelete() { + val articleDelete = ArticleDelete( + gallId = "github", + articleId = articleId, + session = KotlinInside.getInstance().session + ) + + val deleteResult = articleDelete.delete() + + println(deleteResult) + } }