diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad..029107c 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -27,4 +27,6 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } + +public string? Icon { get; set; } } \ No newline at end of file diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181..44f725a 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -14,31 +14,34 @@ public GoalControllerTests() { collections = new(); } +[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); - [Fact] - public async void GetAll() - { - // 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.Get(); + // Act + var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext(); + controller.ControllerContext.HttpContext = httpContext; + var result = await controller.GetForUser(users[0].Id!); - // Assert - var index = 0; - foreach (Goal goal in result) - { - Assert.IsAssignableFrom(goal); - Assert.Equal(goals[index].Id, goal.Id); - Assert.Equal(goals[index].Name, goal.Name); - index++; - } + // Assert + Assert.NotNull(result); + Assert.IsAssignableFrom>(result); + Assert.Equal(goals.Count, result.Count); + + var index = 0; + foreach (Goal goal in result) + { + Assert.Equal(goals[index].Id, goal.Id); + Assert.Equal(goals[index].Name, goal.Name); + index++; + } +} } [Fact] diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..84d087c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "CommBank-Server", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}