As i am new to moq and Nunit, i dont know how to unit test the business service. I have the business service called studentdetailsbs.cs,i need to test whether fetchallstudents returns studentlist or not. More over internally the studentdetailbs class goes to unitofwork class and this again goes to respository class and gets data from entity framework.
public class StudentDetailbs<TEntity> :IStudentbs<TEntity> where TEntity:class
{
IUnitofwork _uow;
//here unitofwork is inejcted
public StudentDetailbs(IUnitofwork iunitofwork)
{
this._uow = iunitofwork;
}
public void Add(TEntity tentity)
{
//now call the studentdetail
StudentDetail objstudentdetail = (StudentDetail)(object)(tentity);
this._uow.StudentRepo.Add(objstudentdetail);
this._uow.Save();
}
public IEnumerable<StudentDetail> FetchallStudents()
{
return this._uow.StudentRepo.GetAll();
}
}
my final questions are:
1.whether fetchallstudents method returns student list or not.
2.Whether add method properly inserts student record into database.
How to do this using Nunit and moq? Any suggestions.
Aucun commentaire:
Enregistrer un commentaire