|
|
@ -4,16 +4,24 @@ import org.junit.Assert.assertEquals
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.Test
|
|
|
|
import com.example.what_the_fantasy.data.services.IServices
|
|
|
|
import com.example.what_the_fantasy.data.services.IServices
|
|
|
|
import com.example.what_the_fantasy.data.services.ServicesStub
|
|
|
|
import com.example.what_the_fantasy.data.services.ServicesStub
|
|
|
|
|
|
|
|
import org.junit.Assert.assertFalse
|
|
|
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
|
|
|
|
|
|
|
|
class UnitTestQuote {
|
|
|
|
class UnitTestQuote {
|
|
|
|
private val services : IServices = ServicesStub()
|
|
|
|
private val services : IServices = ServicesStub()
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun testGetQuote(){
|
|
|
|
fun testGetQuote_OK(){
|
|
|
|
val quote = services.getQuote(1)
|
|
|
|
val quote = services.getQuote(1)
|
|
|
|
assertEquals("All we have to decide is what to do with the time that is given us.",quote?.content)
|
|
|
|
assertEquals("All we have to decide is what to do with the time that is given us.",quote?.content)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun testGetQuote_Fake(){
|
|
|
|
|
|
|
|
val quote = services.getQuote(-1)
|
|
|
|
|
|
|
|
assertEquals(null,quote?.content)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun testGetSomeQuote_OK(){
|
|
|
|
fun testGetSomeQuote_OK(){
|
|
|
|
val quote = services.getSomeQuotes(4,1)
|
|
|
|
val quote = services.getSomeQuotes(4,1)
|
|
|
@ -21,13 +29,19 @@ class UnitTestQuote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun testGetSomeQuoteNegatif(){
|
|
|
|
fun testGetSomeQuoteIndexNegatif(){
|
|
|
|
val quote = services.getSomeQuotes(-1,1)
|
|
|
|
val quote = services.getSomeQuotes(-1,1)
|
|
|
|
assertEquals(1,quote.size)
|
|
|
|
assertEquals(1,quote.size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun testGetSomeQuote0(){
|
|
|
|
fun testGetSomeQuotePageNegatif(){
|
|
|
|
|
|
|
|
val quote = services.getSomeQuotes(1,-1)
|
|
|
|
|
|
|
|
assertEquals(1,quote.size)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun testGetSomeQuoteIndex0(){
|
|
|
|
val quote = services.getSomeQuotes(0,1)
|
|
|
|
val quote = services.getSomeQuotes(0,1)
|
|
|
|
assertEquals(0,quote.size)
|
|
|
|
assertEquals(0,quote.size)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -126,5 +140,22 @@ class UnitTestQuote {
|
|
|
|
assertEquals(0,quote.size)
|
|
|
|
assertEquals(0,quote.size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun testIsFavorite_OK(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertTrue(services.isFavorite(1,10))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun testIsFavorite_FakeQuote(){
|
|
|
|
|
|
|
|
assertFalse(services.isFavorite(-1,10))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun testIsFavorite_FakeUser(){
|
|
|
|
|
|
|
|
assertFalse(services.isFavorite(1,-1))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|