From a2fa011e1804839a1649ad7a7b37850059952576 Mon Sep 17 00:00:00 2001 From: nnn-bit Date: Mon, 8 Jun 2026 20:17:18 +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..81f01923 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -11,6 +11,8 @@ public class Goal public string? Name { get; set; } + public string? Icon { get; set; } + public UInt64 TargetAmount { get; set; } = 0; public DateTime TargetDate { get; set; } From ce1b426ce6e133d31256e71416edd39e9e4a2f62 Mon Sep 17 00:00:00 2001 From: nnn-bit Date: Wed, 10 Jun 2026 12:46:45 +0530 Subject: [PATCH 2/2] Add GetForUser goal controller test --- CommBank.Tests/GoalControllerTests.cs | 30 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..df5b3d59 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -63,12 +63,30 @@ public async void Get() } [Fact] - public async void GetForUser() +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(users[0].Id!); + + // Assert + Assert.NotNull(result); + + var index = 0; + foreach (Goal goal in result!) { - // Arrange - - // Act - - // Assert + Assert.IsAssignableFrom(goal); + Assert.Equal(goals[index].Id, goal.Id); + Assert.Equal(goals[index].Name, goal.Name); + index++; } +} } \ No newline at end of file