Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First phase of technical tests #27

Merged
merged 17 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions testomania/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
implementation 'androidx.activity:activity-compose:1.4.0'

//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'

//Glide
implementation 'com.github.bumptech.glide:glide:4.13.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'

// Serialization
implementation("com.squareup.moshi:moshi-kotlin:1.13.0")
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.13.0")
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"

// Compose dependencies
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AppModule {

//TODO provide DB instance and so on
@Provides
@Singleton
fun provideOkHttpClient() = OkHttpClient()

@Provides
@Singleton
fun jsonSerializer(): Moshi {
Expand Down
4 changes: 0 additions & 4 deletions testomania/src/main/java/com/earth/testomania/domain/Test.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.earth.testomania.technical.di

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import javax.inject.Singleton
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import javax.inject.Named


private const val QUIZ_API_NAME = "QUIZ_API"
private const val QUIZ_API_BASE_URL = "https://quizapi.io/api/v1/questions"

@Module
@InstallIn(SingletonComponent::class)
class TechnicalTestsModule {

@Provides
@Singleton
@Named(QUIZ_API_NAME)
fun provideQuizAPIRetrofit(okHttpClient: OkHttpClient): Retrofit = Retrofit.Builder()
.baseUrl(QUIZ_API_BASE_URL)
.client(okHttpClient)
.addConverterFactory(MoshiConverterFactory.create())
.build()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.earth.testomania.technical.domain.model

data class Answers(
val answer_a: String,
val answer_b: String,
val answer_c: Any,
val answer_d: Any,
val answer_e: Any,
val answer_f: Any
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.earth.testomania.technical.domain.model

data class CorrectAnswers(
Nodrex marked this conversation as resolved.
Show resolved Hide resolved
val answer_a_correct: String,
val answer_b_correct: String,
val answer_c_correct: String,
val answer_d_correct: String,
val answer_e_correct: String,
val answer_f_correct: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.earth.testomania.technical.domain.model

data class Tag(
val name: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.earth.testomania.technical.domain.model

class TechQuiz : ArrayList<TechQuizItem>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.earth.testomania.technical.domain.model

data class TechQuizItem(
val answers: Answers,
val category: String,
val correct_answer: String,
val correct_answers: CorrectAnswers,
val description: Any,
val difficulty: String,
val explanation: Any,
val id: Int,
val multiple_correct_answers: String,
val question: String,
val tags: List<Tag>,
val tip: Any
)
17 changes: 0 additions & 17 deletions testomania/src/test/java/com/earth/testomania/ExampleUnitTest.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.earth.testomania
package com.earth.testomania.skills

import com.earth.testomania.skills.GeneralSkillsMathematicalRepo
import com.google.common.truth.Truth
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
Expand All @@ -13,7 +12,7 @@ import javax.inject.Inject

@RunWith(RobolectricTestRunner::class)
@HiltAndroidTest
class GeneralSkillsTest {
class GeneralSkillsMathematicalRepoTest {

@get:Rule
var hiltRule = HiltAndroidRule(this)
Expand All @@ -39,4 +38,5 @@ class GeneralSkillsTest {
Truth.assertThat(repo.getRandomTests(count))
.hasSize(count)
}

}