package io.trustbuilder.mfa.android.demoapp.utils;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;

import java.util.ArrayList;
import java.util.List;

import io.trustbuilder.mfa.lib.definition.CredTypeEnum;
import io.trustbuilder.mfa.lib.usecase.definition.CredMode;
import io.trustbuilder.mfa.lib.usecase.definition.CredProperties;
import io.trustbuilder.mfa.lib.usecase.definition.CredentialProvider;

@RunWith(RobolectricTestRunner.class)
public class CredentialProviderHandlerTest {
    @Test
    public void resolveCredentialProviderFromList_withBio() {
        List<CredentialProvider> credentialProviders = new ArrayList<>();
        CredentialProvider credentialProviderBio = CredentialProvider.builder().credType(CredTypeEnum.BIO).build();
        CredentialProvider credentialProviderSecretCode = CredentialProvider.builder().credType(CredTypeEnum.SECRET_CODE).build();
        credentialProviders.add(credentialProviderBio);
        credentialProviders.add(credentialProviderSecretCode);
        CredentialProviderHandler handler = new CredentialProviderHandler();
        CredentialProvider result = handler.resolveCredentialProviderFromList(credentialProviders);
        Assert.assertEquals(CredTypeEnum.BIO, result.getCredType());
    }

    @Test
    public void resolveCredentialProviderFromList_withoutBio() {
        List<CredentialProvider> credentialProviders = new ArrayList<>();
        CredentialProvider credentialProviderSecretCode = CredentialProvider.builder().credType(CredTypeEnum.SECRET_CODE).build();
        CredentialProvider credentialProviderSecureToken = CredentialProvider.builder().credType(CredTypeEnum.SECURE_TOKEN_ONLY).build();
        credentialProviders.add(credentialProviderSecretCode);
        credentialProviders.add(credentialProviderSecureToken);
        CredentialProviderHandler handler = new CredentialProviderHandler();
        CredentialProvider result = handler.resolveCredentialProviderFromList(credentialProviders);
        Assert.assertEquals(CredTypeEnum.SECRET_CODE, result.getCredType());
    }
}
