VirtoCommerce/vc-module-order

Use Hangfire Interfaces instead of Static methods

kamilgarey opened this issue · 3 comments

For example here:
https://github.com/VirtoCommerce/vc-module-order/blob/dev/VirtoCommerce.OrderModule.Data/Handlers/AdjustInventoryOrderChangedEventHandler.cs

One should use IBackgroundJobClient.Enqueue instead of BackgroundJob.Enqueue.
We have problems with unit tests - which were solved by using actually private(protected) methods which now marked as public.

This should be changed here and in other places.

yecli commented

Could you describe what kind of test do you want to add?
Are you going to test Handle method and check how many times it would be called?

In general I agree that better not to use static methods for jobs processing, just want to know if there is a real need in that change.

Actually you can postpone this issue. It's not so easy to make a stub for a hangfire( at least in case I need).
Enqueue realized in Extension (is static method). So we can't change it by using stubs, mocks, etc. There is technique to change type, but it's a dirty practice.

IBackgroundJobClient.Create is called in extension. But It's prepared for storing to DB or another storage.
I should do reflection, deserealisation. Or I should call Hangfire methods. So it also not easy. as well.

This issue has been closed because it has been inactive for a long time
You may reopen this issue if it has been closed in error.