diff --git a/CommBank-Server/CommBank.csproj b/CommBank-Server/CommBank.csproj index 983cc882..8397b331 100644 --- a/CommBank-Server/CommBank.csproj +++ b/CommBank-Server/CommBank.csproj @@ -1,11 +1,12 @@ - + - net6.0 + net10.0 enable enable CommBank_Server CommBank-Server + 87ed61c0-58ee-42aa-ac5d-6869104ac2a5 diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..a67d2a12 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -3,6 +3,7 @@ namespace CommBank.Models; +[BsonIgnoreExtraElements] public class Goal { [BsonId] @@ -27,4 +28,7 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } + + [BsonElement("Icon")] + public string? Icon { get; set; } } \ No newline at end of file diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json deleted file mode 100644 index 0e5bf949..00000000 --- a/CommBank-Server/Secrets.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" - } -} \ No newline at end of file diff --git a/CommBank-Server/appsettings.json b/CommBank-Server/appsettings.json index af0538f7..3479bf1f 100644 --- a/CommBank-Server/appsettings.json +++ b/CommBank-Server/appsettings.json @@ -5,6 +5,10 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "MongoDbSettings": { + "ConnectionString": "{CONNECTION_STRING}", + "DatabaseName": "rSERVER" + } } diff --git a/CommBank.Tests/CommBank.Tests.csproj b/CommBank.Tests/CommBank.Tests.csproj index 4d9413f4..3ca5f278 100644 --- a/CommBank.Tests/CommBank.Tests.csproj +++ b/CommBank.Tests/CommBank.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net10.0 enable enable diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..a66fe096 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -3,6 +3,7 @@ using CommBank.Models; using CommBank.Tests.Fake; using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; namespace CommBank.Tests; @@ -66,9 +67,31 @@ public async void Get() public async void GetForUser() { // Arrange - + var goals = collections.GetGoals(); + var users = collections.GetUsers(); + + var testUser = users[0]; + + IGoalsService goalsService = new FakeGoalsService(goals, goals[0]); + IUsersService usersService = new FakeUsersService(users, testUser); + 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 actionResult = Assert.IsAssignableFrom>(result); + + foreach (Goal goal in result!) + { + Assert.IsAssignableFrom(goal); + Assert.Equal(goals[0].UserId, goal.UserId); + } } + } \ No newline at end of file