Android 深入研究SQLite執行個體(七)

來源:互聯網
上載者:User
package eoe.demo;import java.util.List;import it.bean.Person;import it.service.PersonService;import android.test.AndroidTestCase;import android.util.Log;/**** 執行PersonService的測試**/public class PersonServiceTest extends AndroidTestCase {private static final String tag="PersonServiceTest";public void testsave()throws Exception{PersonService personservice=new PersonService(this.getContext());for(int i=0;i<10;i++){personservice.save(new Person("huhuanhuan",(short)33));}}public void testfindbyid(){PersonService personservice=new PersonService(this.getContext());Person p=personservice.findbyid(1);Log.i(tag,p.toString());}public void testupdate(){Person person=new Person(1,"chun",(short)20);PersonService personservice=new PersonService(this.getContext());personservice.update(person);Person p=personservice.findbyid(1);Log.i(tag,p.toString());}public void testgetdatePerson(){Person p=new Person();PersonService personservice=new PersonService(this.getContext());List list=personservice.getdatePerson(0, 10);for(int i=0;i< p> p=(Person)list.get(i);Log.i(tag,p.toString());}}public void testgetcount(){PersonService personservice=new PersonService(this.getContext());long l=personservice.getcount();Log.i(tag, String.valueOf(l));}public void testdelete(){PersonService personservice=new PersonService(this.getContext());personservice.delete(1,2,3);}}

測試類別代碼

package eoe.demo;import java.util.List;import it.bean.Person;import it.service.PersonSQLservice;import android.test.AndroidTestCase;import android.util.Log;/**** 執行PersonSQLservice 進行測試**/public class PersonSQLserviceTest extends AndroidTestCase {private static final String TAG="PersonSQLserviceTest";public void testsave(){PersonSQLservice psql=new PersonSQLservice(this.getContext());for(int i=0;i<10;i++){psql.save(new Person("李淵", (short)1));}}public void testFind() throws Exception{PersonSQLservice psql=new PersonSQLservice(this.getContext());Person person = psql.find(22);Log.i(TAG, person.toString());}public void testUpdate() throws Exception{PersonSQLservice psql=new PersonSQLservice(this.getContext());Person person = psql.find(1);person.setName("liming");psql.update(person);//Log.i(TAG, person.toString());}public void testGetCount() throws Exception{PersonSQLservice psql=new PersonSQLservice(this.getContext());Log.i(TAG, String.valueOf(psql.getCount()));}public void testGetScrollData() throws Exception{PersonSQLservice psql=new PersonSQLservice(this.getContext());List persons = psql.getScrollData(0, 20);for(Person person : persons){Log.i(TAG, person.toString());}}public void testDelete() throws Exception{PersonSQLservice psql=new PersonSQLservice(this.getContext());psql.delete(1,2,3);}}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.