Bad-Developers-Troop / polarisdesk

4 stars 8 forks source link

Unit test api implementation #24

Closed binick closed 3 years ago

binick commented 3 years ago

The intent of this PR is that to starting a discussion on unit test.

The library used is xunit, shouldly and coverlet

To decouple api controller logic from the application service logic I was thinking about creating a worker service for each controller.

What do you think?

diego81b commented 3 years ago

@binick Worker service intended as a background task? If yes, in my opinion worker service are great for:

Using worker service for all controller seems an overkill. To simply decouple logic from controller we can use a Service Layer design pattern that we can use in dependency injection

My 2 cents 🖖

kasuken commented 3 years ago

Please, do a smaller pull request... :) And try to integrate the unit test with the @diego81b suggestions.

binick commented 3 years ago

@binick Worker service intended as a background task? If yes, in my opinion worker service are great for:

  • Process element on a queue
  • Timed operations
  • long running operations

Using worker service for all controller seems an overkill. To simply decouple logic from controller we can use a Service Layer design pattern that we can use in dependency injection

My 2 cents 🖖

Sure, the worker service in my mind should be represent as a implementation of service layer pattern.

Mostly I've seen the service layer implemented within the classic three layer (controller/service/repository). I don't think bringing up the repository pattern is necessary either. So I tried an alternative (unhappy 😄) name.