1 package net.pterodactylus.sone.data
3 import net.pterodactylus.sone.test.*
4 import org.hamcrest.MatcherAssert.*
5 import org.hamcrest.Matchers.*
9 * Unit test for [Profile].
13 private val sone = mock<Sone>()
14 private val profile = Profile(sone)
17 fun `first name is initialized with null`() {
18 assertThat(profile.firstName, nullValue())
22 fun `setting first name to value will set it to value`() {
23 profile.firstName = "first name"
24 assertThat(profile.firstName, equalTo("first name"))
28 fun `setting first name to null will set it to null`() {
29 profile.firstName = null
30 assertThat(profile.firstName, nullValue())
34 fun `setting first name to empty string will set it to null`() {
35 profile.firstName = ""
36 assertThat(profile.firstName, nullValue())
40 fun `middle name is initialized with null`() {
41 assertThat(profile.middleName, nullValue())
45 fun `setting middle name to value will set it to value`() {
46 profile.middleName = "middle name"
47 assertThat(profile.middleName, equalTo("middle name"))
51 fun `setting middle name to null will set it to null`() {
52 profile.middleName = null
53 assertThat(profile.middleName, nullValue())
57 fun `setting middle name to empty string will set it to null`() {
58 profile.middleName = ""
59 assertThat(profile.middleName, nullValue())
63 fun `last name is initialized with null`() {
64 assertThat(profile.lastName, nullValue())
68 fun `setting last name to value will set it to value`() {
69 profile.lastName = "last name"
70 assertThat(profile.lastName, equalTo("last name"))
74 fun `setting last name to null will set it to null`() {
75 profile.lastName = null
76 assertThat(profile.lastName, nullValue())
80 fun `setting last name to empty string will set it to null`() {
82 assertThat(profile.lastName, nullValue())
86 fun `new fields are initialized with an empty string`() {
87 val newField = profile.addField("testField")
88 assertThat(newField.value, equalTo(""))