- I have this scenario: an interface with 2 methods
- the 2 methods take requests and return response
- Methods contain functionality inside (check permissions and validate request and get data from database using entity framework.
- But I want to test the methods and not just the interface.
- I've tested the interface successfully but now I want to enter the method and test inside it.
Code example:
public interface IMyInterface
{
[OperationContract]
responseObject GetData(Service<RequestObject> request);
}
public class MyConcreteClass : IMyInterface
{
public responseObject GetData(Service<RequestObject> request)
{
CheckForNull(request);
ValidateMethod(request);
//connect to db
using(var context = new contextEntity)
{
//get data
}
}
}
Now, I want to test the check nulls, permissions and data access, is it possible? Or do I have to extract interface from the internal methods?
PS, this is for my unit testing. I'm trying to eliminate external dependencies. please explain in detail
Aucun commentaire:
Enregistrer un commentaire