Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e06956d authored by Philip Whitehouse's avatar Philip Whitehouse
Browse files

Tests for OpenPgpApiHelper

parent c60f97fb
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
package com.fsck.k9.crypto;


import com.fsck.k9.Identity;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.assertEquals;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
public class OpenPgpApiHelperTest {

    @Test
    public void buildUserId_withName_shouldCreateOpenPgpAccountName() {
        Identity identity = new Identity();
        identity.setEmail("user@domain.com");
        identity.setName("Name");

        String result = OpenPgpApiHelper.buildUserId(identity);

        assertEquals("Name <user@domain.com>", result);
    }

    @Test
    public void buildUserId_withoutName_shouldCreateOpenPgpAccountName() {
        Identity identity = new Identity();
        identity.setEmail("user@domain.com");

        String result = OpenPgpApiHelper.buildUserId(identity);

        assertEquals("<user@domain.com>", result);
    }

}