Skip to content

Implement CRUD operations in UserController #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

github-cloudlabsuser-2113

This commit introduces a series of significant updates to the UserController.cs and adds unit tests in UserControllerTests.cs. In UserController.cs, we have implemented CRUD operations fo#r the User model, including methods for Index, Details, Create (GET and POST), Edit (GET and POST), and Delete (GET and POST). These methods interact with a static list named userlist that serves as a temporary database, facilitating operations like adding, editing, and deleting users. Additionally, the commit includes the creation of the namespace CRUD_application_2.Controllers to house the UserController class.

For UserControllerTests.cs, we have added unit tests using NUnit and Moq to verify the functionality of the UserController methods. The tests cover the Index, Details, and Create methods, ensuring they behave as expected when interacting with the static userlist. These tests include scenarios where users are successfully found, added, or not found, leading to appropriate responses such as views with user data or HttpNotFound results.

Overall, this commit significantly enhances the application's ability to manage users through the UserController and ensures the reliability of these features through comprehensive unit testing.

Refactor UserController & add unit tests

  • Refactored UserController.cs by removing unnecessary comments and implementing core CRUD functionalities for user management. This includes enhancements to the Index, Details, Create, Edit, and Delete actions to ensure they perform as expected, handling both success and error scenarios appropriately.
  • Enhanced the Index action to return a view with a list of all users, and the Details action now searches for a user by ID, returning user details or a HttpNotFound result based on the user's existence.
  • Improved the Create action with GET and POST handlers for adding new users, including error handling. Similarly, the Edit action has been updated to allow for user information updates with proper error checking. The Delete action now supports user removal with confirmation.
  • Introduced UserControllerTests.cs, utilizing the NUnit framework for unit testing the UserController. This includes setting up a test environment with a simulated user list and implementing tests for the Index, Details, and Create actions to verify their functionality and error handling.
  • Utilized Moq and NUnit in the test class for mocking dependencies and assertions, enhancing the reliability of the tests.

This commit introduces a series of significant updates to the UserController.cs and adds unit tests in UserControllerTests.cs. In UserController.cs, we have implemented CRUD operations fo#r the User model, including methods for Index, Details, Create (GET and POST), Edit (GET and POST), and Delete (GET and POST). These methods interact with a static list named `userlist` that serves as a temporary database, facilitating operations like adding, editing, and deleting users. Additionally, the commit includes the creation of the namespace `CRUD_application_2.Controllers` to house the UserController class.

For UserControllerTests.cs, we have added unit tests using NUnit and Moq to verify the functionality of the UserController methods. The tests cover the Index, Details, and Create methods, ensuring they behave as expected when interacting with the static `userlist`. These tests include scenarios where users are successfully found, added, or not found, leading to appropriate responses such as views with user data or `HttpNotFound` results.

Overall, this commit significantly enhances the application's ability to manage users through the UserController and ensures the reliability of these features through comprehensive unit testing.

Refactor UserController & add unit tests

- Refactored UserController.cs by removing unnecessary comments and implementing core CRUD functionalities for user management. This includes enhancements to the Index, Details, Create, Edit, and Delete actions to ensure they perform as expected, handling both success and error scenarios appropriately.
- Enhanced the Index action to return a view with a list of all users, and the Details action now searches for a user by ID, returning user details or a HttpNotFound result based on the user's existence.
- Improved the Create action with GET and POST handlers for adding new users, including error handling. Similarly, the Edit action has been updated to allow for user information updates with proper error checking. The Delete action now supports user removal with confirmation.
- Introduced UserControllerTests.cs, utilizing the NUnit framework for unit testing the UserController. This includes setting up a test environment with a simulated user list and implementing tests for the Index, Details, and Create actions to verify their functionality and error handling.
- Utilized Moq and NUnit in the test class for mocking dependencies and assertions, enhancing the reliability of the tests.
Added a new ARM template `deploy.json` for deploying an Azure SQL Server and a SQL Database, including configurations like version, collation, and maxSizeBytes. A parameters file `deploy.parameters.json` was also added to provide placeholder values for the deployment parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant