From 3eb6451e6eb53abc5a626d76418a4e289d387764 Mon Sep 17 00:00:00 2001 From: Kyaw Paing Oo <82670447+Kyawpaingoo@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:09:23 +0630 Subject: [PATCH] Support Icons --- CommBank-Server/Models/Goal.cs | 1 + CommBank.Tests/GoalControllerTests.cs | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad..7d4ace1 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -24,6 +24,7 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public List? TagIds { get; set; } + public string? Icons { get; set; } [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181..048f9e1 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -66,9 +66,24 @@ public async void Get() public async void GetForUser() { // Arrange - + var goals = collections.GetGoals(); + var users = collections.GetUsers(); + IGoalsService goalService = new FakeGoalsService(goals, goals[0]); + IUsersService userService = new FakeUsersService(users, users[0]); + GoalController controller = new(goalService, userService); // Act - + var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext(); + controller.ControllerContext.HttpContext = httpContext; + var result = await controller.GetForUser(goals[0].Id!); // 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