package com.fsck.k9.mailstore;


import android.test.AndroidTestCase;

import com.fsck.k9.Preferences;
import com.fsck.k9.mail.internet.MimeBodyPart;
import com.fsck.k9.mail.internet.MimeMultipart;


public class LocalMessageTest extends AndroidTestCase {
    private LocalMessage message;

    @Override
    public void setUp() throws Exception {
        super.setUp();
        Preferences preferences = Preferences.getPreferences(getContext());
        LocalStore store = LocalStore.getInstance(preferences.newAccount(), getContext());
        message = new LocalMessage(store, "uid", new LocalFolder(store, "test"));
    }

    public void testGetDisplayTextWithPlainTextPart() throws Exception {
        String textBodyText = "text body";

        MimeMultipart multipart = new MimeMultipart();
        MimeBodyPart bodyPart1 = new MimeBodyPart(new LocalTextBody(textBodyText, textBodyText), "text/plain");
        multipart.addBodyPart(bodyPart1);
        message.setBody(multipart);
        assertEquals("text body", message.getTextForDisplay());
    }

    public void testGetDisplayTextWithHtmlPart() throws Exception {
        String htmlBodyText = "html body";
        String textBodyText = "text body";

        MimeMultipart multipart = new MimeMultipart();
        MimeBodyPart bodyPart1 = new MimeBodyPart(new LocalTextBody(htmlBodyText, htmlBodyText), "text/html");
        MimeBodyPart bodyPart2 = new MimeBodyPart(new LocalTextBody(textBodyText, textBodyText), "text/plain");
        multipart.addBodyPart(bodyPart1);
        multipart.addBodyPart(bodyPart2);
        message.setBody(multipart);
        assertEquals("html body", message.getTextForDisplay());
    }
}

@@ -45,159 +45,472 @@
 oid.
+con
 te
-st.AndroidTestCase;%0A%0Aimport com.fsck.k9.Preferences;%0Aimport com.fsck.k9.mail.internet.MimeBodyPart;%0Aimport com.fsck.k9.mail.internet.MimeMultipart;%0A%0A
+nt.Context;%0Aimport android.support.test.InstrumentationRegistry;%0Aimport android.support.test.runner.AndroidJUnit4;%0A%0Aimport com.fsck.k9.Account;%0Aimport com.fsck.k9.Preferences;%0Aimport com.fsck.k9.mail.internet.MimeBodyPart;%0Aimport com.fsck.k9.mail.internet.MimeMultipart;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0A%0Aimport static junit.framework.Assert.assertEquals;%0A%0A%0A@RunWith(AndroidJUnit4.class)
 %0Apub
@@ -540,32 +540,8 @@
 est 
-extends AndroidTestCase 
 %7B%0A  
@@ -576,108 +576,213 @@
 ge;%0A
-%0A    @Override%0A    public void setUp() throws Exception %7B%0A        super.setUp();%0A        Preferences
+    private Account account;%0A    private Preferences preferences;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        Context targetContext = InstrumentationRegistry.getTargetContext();%0A       
  pre
@@ -819,16 +819,19 @@
 erences(
+tar
 getConte
@@ -824,34 +824,76 @@
 es(targetContext
-(
 )
+;%0A        account = preferences.newAccount(
 );%0A        Local
@@ -933,34 +933,20 @@
 nce(
-preferences.newA
+a
 ccount
-()
 , 
+tar
 getC
@@ -951,18 +951,16 @@
 tContext
-()
 );%0A     
@@ -1035,32 +1035,150 @@
 test%22));%0A    %7D%0A%0A
+    @After%0A    public void tearDown() throws Exception %7B%0A        preferences.deleteAccount(account);%0A    %7D%0A%0A    @Test%0A
     public void 
@@ -1590,24 +1590,34 @@
 ());%0A    %7D%0A%0A
+    @Test%0A
     public v

Remove account after creation