Skip to content

Commit

Permalink
테스트 케이스 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed Oct 23, 2019
1 parent 84db213 commit da28859
Showing 1 changed file with 76 additions and 7 deletions.
83 changes: 76 additions & 7 deletions src/test/kotlin/be/zvz/kotlininside/KotlinInsideTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit da28859

Please sign in to comment.