I´m new on unit testing. I am developing a MVC project with a Service Layer where I do all business logic and access to database (through repository pattern)
I create a project to unit test my business logic, like that:
Service layer example logic I want to test:
public static bool HasPermissionToSomething(MyDomain domain)
{
if((domain.prop1 == true || domain.prop3 == false) && domain.prop2 == false)
return true;
return false;
}
So I created a unit test like that (using XUnit)
[Fact]
public void HasPermissionToSomethingTest()
{
var domain = MockDomain();
var hasPermission = MyService.HasPermissionToSomething(domain);
Assert.Equal(hasPermission, true);
}
Is that a good approach to test my service layer? Is my test a good one?
Thanks
Aucun commentaire:
Enregistrer un commentaire