lundi 19 avril 2021

How to create complex Integration Test with 2 Web API using C# (NUnit)?

I have an application that works as shown on the figure:

My app scheme

The idea behind is:

Both Web API (Web API #1, Web API #2) are part of my application (2 projects in 1 solution).

step 1: Requesting the endpoint of Web API #1. Web API #1 stores a record to database with status NEW.

step 2: Web API #1 returns a response to a caller (For example: Your request has been accepted).

step 3: Web API #1 has a demon inside. The demon sees a new record in the database with status NEW and make a request to Web API #2.

step 4: Web API #2 do some work (For example: 10 seconds) and returns a response to Web API #1. Web API #1 updated the record in database with status PROCESSED.

I know how to test the endpoint of Web API #1 (WebApplicationFactory etc...), but I want to test full cycle: request to Web API #1 -> record with status NEW -> request to Web API #2 -> response -> record with status Processed -> We have record with status PROCESSED? => Test is done.

Aucun commentaire:

Enregistrer un commentaire