From f7fbaa92d97ebe2315aa216b8ced5ff9070c874e Mon Sep 17 00:00:00 2001 From: shubh Date: Tue, 18 Aug 2026 16:00:46 +0530 Subject: [PATCH 1/2] Add optional icon field to Goal model --- CommBank-Server/Models/Goal.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..9b200393 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -7,7 +7,9 @@ public class Goal { [BsonId] [BsonRepresentation(BsonType.ObjectId)] + public string? Id { get; set; } + public string? Icon { get; set; } public string? Name { get; set; } From fc454ae58b1b999bee8e61769ca19d660ba105b5 Mon Sep 17 00:00:00 2001 From: shubh Date: Wed, 19 Aug 2026 17:53:07 +0530 Subject: [PATCH 2/2] Add unit tests for GetGoalsForUser --- CommBank.Tests/CommBank.Tests.csproj | 1 + CommBank.Tests/GoalControllerTests.cs | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CommBank.Tests/CommBank.Tests.csproj b/CommBank.Tests/CommBank.Tests.csproj index 4d9413f4..3dec2de2 100644 --- a/CommBank.Tests/CommBank.Tests.csproj +++ b/CommBank.Tests/CommBank.Tests.csproj @@ -10,6 +10,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..a65bbadd 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -63,12 +63,30 @@ public async void Get() } [Fact] + public async void GetForUser() { // Arrange - + var goals = collections.GetGoals(); + var users = collections.GetUsers(); + IGoalsService goalsService = new FakeGoalsService(goals, goals[0]); + IUsersService usersService = new FakeUsersService(users, users[0]); + GoalController controller = new(goalsService, usersService); + // Act - + var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext(); + controller.ControllerContext.HttpContext = httpContext; + var result = await controller.GetForUser(goals[0].UserId!); + // Assert + Assert.NotNull(result); + + var index = 0; + foreach (Goal goal in result!) + { + Assert.IsAssignableFrom(goal); + Assert.Equal(goals[0].UserId, goal.UserId); + index++; + } } } \ No newline at end of file