Skip to content

Conversation

@MSavameri
Copy link
Owner

This commit introduces unit tests for the POST Create action in NetworkController. The following scenarios are covered:

  • Posting a valid NetworkAssetDto, expecting a RedirectToAction.
  • Posting an invalid NetworkAssetDto, expecting a ViewResult with model errors.
  • Handling cases where a missing user claim leads to a null UserName, and the service layer throws an ArgumentNullException which is caught and rethrown by the controller.
  • Handling general exceptions thrown by the network service, expecting an Error view.

The tests utilize Moq for mocking dependencies and FluentAssertions for assertions.

Additionally, several compiler warnings related to nullability (CS8604, CS8602, CS8603, CS8618) and redundant checks (CS8073) were addressed in both NetworkInfrastructure.Web and NetworkInfrastructure.Tests projects during the test development process.

This commit introduces unit tests for the POST Create action in NetworkController.
The following scenarios are covered:
- Posting a valid NetworkAssetDto, expecting a RedirectToAction.
- Posting an invalid NetworkAssetDto, expecting a ViewResult with model errors.
- Handling cases where a missing user claim leads to a null UserName, and the service layer throws an ArgumentNullException which is caught and rethrown by the controller.
- Handling general exceptions thrown by the network service, expecting an Error view.

The tests utilize Moq for mocking dependencies and FluentAssertions for assertions.

Additionally, several compiler warnings related to nullability (CS8604, CS8602, CS8603, CS8618) and redundant checks (CS8073) were addressed in both NetworkInfrastructure.Web and NetworkInfrastructure.Tests projects during the test development process.
@MSavameri MSavameri merged commit 456901b into master Jun 5, 2025
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.

2 participants