Android 深入研究SQLite实例(七)

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);
}

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值