Refactor Unit Test based on Requirement For Negative Scenarios
Reason for code refactor
- Both request and response are of same type
- We have the processor sitting in the same test project as the tests i.e. everyting is inside the test project. None of these resources, which are the real resources for the application, should really be inside of the test project like Models and Services.
So we are going to come back and we're going to refactor our project and move away. What needs to be moved away, fix all the references and fix up the code so that there's less repetition all around.
Restructuring and Refactoring
- Create Another Project of type ‘Class LIbrary’ (double click on left side)
- Create folder Models and move both request and response file into this folder. change namecepance accordintly
- Add referene of class library into the test project
- Manage Reference of both class as per referenced Project in Test Project
The separation of concerns restricted not only the creation of distinct model files but also ensuring that relevant class files or assets are centralised in a singular location.
- Create a sperate folder Services/Processors in Class Libary
- Move our servie from test projec to this folder in class libary
- Manage Reference of processor/service class as per referenced Project in Test Project
Rebuild both the projects and run test again
Running successfully
