I need to develop a microservice that needs to receive an event. If the data update was successful, then you need to forcefully kill the process(Process.Kill()). Otherwise, send to the message broker that the operation was not successful and needs to be restarted. I encountered a problem that when I kill a process, the execution of the component test automatically ends.
if (result.Success){
var _ = Task.Factory.StartNew(async () => {
try
{
await Task.Delay(1);
var currentProcess = _processProvider.GetCurrentProcess();
currentProcess.Kill()
}
catch
{
...
}
}
}
return Result.Restart;
I set Task to wait for one second before killing the process. It works, but service have to wait longer to pass the tests. And in production, setting it to 10 seconds will greatly affect performance. I thought that I could move the process receiving into a separate service and then mock it. Is it possible to mock services in component tests? Or what is the best way how to solve that challange?
Maksim Silkou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.