/*
 *
 * Nextcloud Android client application
 *
 * @author Tobias Kaminsky
 * Copyright (C) 2020 Tobias Kaminsky
 * Copyright (C) 2020 Nextcloud GmbH
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */
package com.owncloud.android.ui

import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
class TextDrawableTest {

    @Parameterized.Parameter(0)
    lateinit var expected: String

    @Parameterized.Parameter(1)
    lateinit var input: String

    @Test
    fun twoDigitAvatars() {
        assertEquals(
            "Avatar chars from displayname not correct",
            expected,
            TextDrawable.extractCharsFromDisplayName(input)
        )
    }

    companion object {
        @Parameterized.Parameters(name = "{1}")
        @JvmStatic
        fun data(): Iterable<Array<String>> = listOf(
            arrayOf("A", "Admin"),
            arrayOf("TS", "Test Server Admin"),
            arrayOf("", ""),
            arrayOf("CP", "Cormier Paulette"),
            arrayOf("WB", "winston brent"),
            arrayOf("BJ", "Baker James Lorena"),
            arrayOf("BJ", "Baker  James   Lorena"),
            arrayOf("E", "email@nextcloud.localhost"),
            arrayOf("SA", "  Spaces At Start"),
            arrayOf("SA", "Spaces At End   "),
            arrayOf("SA", "  Spaces At Start And End   "),
            arrayOf("", "  ")
        )
    }
}
