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.
Task 1: Modify an Existing .NET Backend
Aim
The aim is to support icons, by extending our existing .NET backend written in C#.
Tools
MongoDB: Seeding your development instance.
C# and .NET: Modify the Goal model
Postman: Manual testing
Result
cwbank.postman_collection.json: Describes the server response
Steps
Fork rSERVER:
Fork https://github.com/fencer-so/commbank-server using GitHub GUI
Connect Server To Database:
File: Secrets.json
Description:
In the secrets.json file. The Mongo DB connection string is added.
File: Goal.cs
Description:
In the Goal.cs file. There is an addition of an optional public Icon field of string type.
Task 4: Cover Your Code!
Aim
The aim is to cover the icons.
Tools
xUnit testing framework: Used to cover the changes.
Result
GoalControllerTests.cs:
Steps
Description:
Arranged Dependencies:
I've set up the necessary dependencies for the GoalController, including mocked versions of goalsService and usersService. We're using FakeGoalsService and FakeUsersService for this purpose.
Acted to Retrieve Goals:
The test now creates an HTTP context and assigns it to the controller's ControllerContext.HttpContext. Then, it calls the GetForUser method of the GoalController, passing in the user ID of the first goal.
Assertions:
I've added assertions to ensure the correctness of the results.
First, it asserts that the result is not null.
Then, it iterates through each goal in the result, ensuring that each one is of type Goal and that its UserId matches the user ID of the first goal.