/unit-tests-mocks

Unit-testing, decoupling, mocking with Moq framework in C#

Primary LanguageC#MIT LicenseMIT

Unit Testing with Mocking

C# .NET Moq NUnit

This is a test project for Back-End Tehnologies January 2024 Course @ SoftUni


Project Description

This repository showcases several test projects designed to demonstrate essential techniques in back-end testing. The focus is primarily on unit testing, decoupling, and using the Moq framework for mocking dependencies in C#.

Core Concepts

  • Unit Testing: Testing individual units of code in isolation to ensure they function as expected.
  • Decoupling: Minimizing dependencies between system components, enabling easier testing and greater modularity.
  • Mocking: Leveraging the Moq framework to create mock objects that simulate real dependencies, allowing for controlled testing scenarios.

Technologies Used

  • Moq: A powerful and flexible mocking framework for .NET that simplifies creating test doubles.
  • NUnit: A widely used testing framework for writing and running tests in .NET environments.

Projects in the Repository

1. GetGreeting Project

  • GetGreeting.Tests: Contains unit tests designed to validate the functionality of the GetGreeting application.
  • GetGreeting: The main application project responsible for generating personalized greetings.

3. ItemManagement Project

  • ItemManagementApp: The main application logic for managing items, including adding, updating, and removing items.
  • ItemManagementLib: A shared library that contains the core functionalities used by the ItemManagementApp.
  • ItemManagementTests: A collection of unit tests written to validate the behavior and functionality of the ItemManagement project.

Requirements

To run and modify these test projects, you’ll need:

  • .NET 6.0 SDK or higher
  • Visual Studio 2022 or later / Visual Studio Codee

Contributing

Contributions are welcome! If you have any improvements or bug fixes, feel free to open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For any questions or suggestions, please reach out to me or open an issue in the repository.


Happy Testing! 🚀