Closed gupta-ankit closed 5 years ago
Hi, I will check to remove the static dictionary or add a parameter to enable/disable that.
I've checked but it's complex to change internal behavior.
First of all, I will update the readme as you said.
Hi I implemented this.
So I hope you consider accepting the pull-request and publish a new version.
Thanks, I'll check and merge your PR as soon as possible.
I am using MemoryStorage for my unit tests to check if background jobs are enqueued. I initialize like this
Hangfire.JobStorage.Current = new MemoryStorage();
During my tests, I often use the following to check the number of enqueued jobs increased.
Hangfire.JobStorage.Current.GetMonitoringApi().EnqueuedCount("default")
Since
MemoryStorage()
uses a static dictionary, the storage is shared across tests, which can be confusing. It is an issue since I am assuming the most common use ofMemoryStorage
is during tests, and therefore I think it might be useful if this point is made clear in the README. Alternatively, a flag to create a new dictionary for storing jobs can be added either to theMemoryStorage
constructor or theMemoryStorageOptions
to allow the developers to make that choice.