This project is a review of Unit Testing in C#. The project contains UnitTesting for variouse objects like strings, numbers, dataes and collections. In addtion, a review about Unit Testing of MVC web controllers and testing Web Api controllers
- .NET Core 7
- xUnit
- FluentAssertions
- FakeItEasy
When naming your tests, follow the correct naming convention: ClassName_MethodName_ExpectedResult
.
When catching exceptions in your tests, do not throw them. It's best to log them to the console or write them in a log file.
When writing unit tests, follow the 3A rule:
- Arrange: Get the variables, classes, methods, and any objects needed for this function to work.
- Act: Execute the function.
- Assert: Confirm by checking whether what you are testing returns what you expected.
Make the object you are testing available globally.
- Testing for strings, datetimes, collections, numbers etc
- Unit testing Web API Controllers
- Unit Testing MVC Controllers
- Clone the repository.
- Open the project in your preferred C# development environment (e.g., Visual Studio, Visual Studio Code).
- Build and run the tests.
Feel free to contribute by opening issues or submitting pull requests. Follow the guidelines in the CONTRIBUTING.md file.
This project is licensed under the MIT License - see the LICENSE.md file for details.