From 1f2d1293ad5b15c6d482cd0818bd5d1821cbaa05 Mon Sep 17 00:00:00 2001 From: victord Date: Wed, 11 Feb 2026 03:06:04 -0500 Subject: [PATCH 1/2] Configured local MongoDB secrets and modified Goal model with Icon field --- .gitignore | 2 ++ CommBank-Server/Models/Goal.cs | 2 ++ CommBank-Server/Program.cs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6769715..6c9ff6a 100644 --- a/.gitignore +++ b/.gitignore @@ -404,4 +404,6 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ +# Secrets.json local +Secrets.local.json diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad..218f390 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -25,6 +25,8 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public List? TagIds { get; set; } + public string? Icon { get; set; } + [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } } \ No newline at end of file diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs index a88e560..e266708 100644 --- a/CommBank-Server/Program.cs +++ b/CommBank-Server/Program.cs @@ -9,7 +9,7 @@ builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); -builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Secrets.json"); +builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Secrets.json").AddJsonFile("Secrets.local.json", optional: true); var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("CommBank")); var mongoDatabase = mongoClient.GetDatabase("CommBank"); From 5e5724d751269aeb8b7583f579a981bbc4aa1869 Mon Sep 17 00:00:00 2001 From: victord Date: Tue, 24 Feb 2026 19:09:23 +1030 Subject: [PATCH 2/2] Unit test for GetGoalForUser in GoalController --- CommBank.Tests/GoalControllerTests.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181..7466d99 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -66,9 +66,26 @@ public async void Get() 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