Server-side tests with C#Bot
The server-side tests in a C#Bot application ensure that the components in the server-side are working as expected. In general, a C#Bot server-side request starts by triggering a controller. The controller that is triggered, and the function run within that controller, depend on which API is used for the request. The controller will then call a method in a service, which is responsible for interacting with the database to perform the requested action. These components are all tested as part of the server-side testing framework.
The server-side tests for a C#Bot application are split into unit tests and integration tests. The unit tests are responsible for ensuring the methods and classes in the server-side work as intended in isolation. This is done by creating mock instances of other classes and making assertions based on expected behaviour.
The integration tests for the server-side ensure the components of the server-side work as intended when they interact with each other. This means that real instances of the components are created and the controller is triggered by the test, as opposed to normal operation, where the controller would be triggered by an API call. The request will then follow the regular path through the server-side, and the output is checked to ensure it is as expected.
The server-side tests can be found in ‘testtarget/Serverside/Tests/’, and are then split into different directories for unit and integration tests.
Was this article helpful?