diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts index edfcc4596..1c27e83d3 100644 --- a/core/model/build.gradle.kts +++ b/core/model/build.gradle.kts @@ -17,8 +17,10 @@ @Suppress("DSL_SCOPE_VIOLATION") plugins { id("kotlin") + `java-test-fixtures` } dependencies { implementation(libs.kotlinx.datetime) + testFixturesImplementation(libs.kotlinx.datetime) } \ No newline at end of file diff --git a/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/AuthorFixtures.kt b/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/AuthorFixtures.kt new file mode 100644 index 000000000..8a9bd80e1 --- /dev/null +++ b/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/AuthorFixtures.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.samples.apps.nowinandroid.core.model.data + +import kotlin.random.Random + +fun Random.nextFakeAuthor( + id: String = nextLong().toString(), + name: String = "Android Dev $id", + imageUrl: String = "https://example.org/dev-android/$id.png", + twitter: String = "@dev-android-$id", + mediumPage: String = "https://medium.com/dev-android/$id", + bio: String = "At vero eos et accusamus et iusto odio dignissimos ducimus qui.", +): Author = Author( + id = id, + name = name, + imageUrl = imageUrl, + twitter = twitter, + mediumPage = mediumPage, + bio = bio, +) diff --git a/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/NewsResourceFixtures.kt b/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/NewsResourceFixtures.kt new file mode 100644 index 000000000..768b47fe2 --- /dev/null +++ b/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/NewsResourceFixtures.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.samples.apps.nowinandroid.core.model.data + +import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Unknown +import kotlin.random.Random +import kotlinx.datetime.Instant + +fun Random.nextFakeNewsResource( + id: String = nextLong().toString(), + title: String = "News resource $id", + content: String = "", + url: String = "https://example.org/news/$id", + headerImageUrl: String? = "https://example.org/news/$id.png", + publishDate: Instant = Instant.fromEpochMilliseconds(0), + type: NewsResourceType = Unknown, + authors: List = emptyList(), + topics: List = emptyList(), +): NewsResource = NewsResource( + id = id, + title = title, + content = content, + url = url, + headerImageUrl = headerImageUrl, + publishDate = publishDate, + type = type, + authors = authors, + topics = topics, +) diff --git a/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/TopicFixtures.kt b/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/TopicFixtures.kt new file mode 100644 index 000000000..0428a493d --- /dev/null +++ b/core/model/src/testFixtures/kotlin/com/google/samples/apps/nowinandroid/core/model/data/TopicFixtures.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.samples.apps.nowinandroid.core.model.data + +import kotlin.random.Random + +fun Random.nextFakeTopic( + id: String = nextLong().toString(), + name: String = "Topic $id", + shortDescription: String = "At vero eos et accusamus.", + longDescription: String = "At vero eos et accusamus et iusto odio dignissimos ducimus qui.", + url: String = "https://example.org/topic/$id", + imageUrl: String = "https://example.org/topic/$id.png" +): Topic = Topic( + id = id, + name = name, + shortDescription = shortDescription, + longDescription = longDescription, + url = url, + imageUrl = imageUrl, +)