Implement CRUD operations in UserController #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 namespaceCRUD_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 orHttpNotFound
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