Skip to content

Instantly share code, notes, and snippets.

@pferreirafabricio
Created September 21, 2023 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pferreirafabricio/0988c7bbc67a241232219a9d5ca99a1c to your computer and use it in GitHub Desktop.
Save pferreirafabricio/0988c7bbc67a241232219a9d5ca99a1c to your computer and use it in GitHub Desktop.
🧪 How to unit test if a Hangfire Job was enqueued with NSubstitute
var _backgroundJobClient = Substitute.For<IBackgroundJobClient>();
await _someService.MethodThatEnqueueSomething("idXXX");
_backgroundJobClient.Received()
.Create(
Arg.Is<Job>(
job => job.Type == typeof(MyJobClass)
&& job.Args[0].ToString() == "idXXX"
),
Arg.Any<EnqueuedState>()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment