diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..54aa384a 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -1,4 +1,4 @@ -using MongoDB.Bson; +using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; namespace CommBank.Models; @@ -11,6 +11,9 @@ public class Goal public string? Name { get; set; } + // New optional Icon field + public string? Icon { get; set; } + public UInt64 TargetAmount { get; set; } = 0; public DateTime TargetDate { get; set; } @@ -27,4 +30,4 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } -} \ No newline at end of file +} diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf949..ae755d12 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,5 @@ -{ +{ "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" + "CommBank": "mongodb+srv://63aaradhyauttekar_db_user:Aaradhya2006@cluster0.wms0gga.mongodb.net/?appName=Cluster0" } -} \ No newline at end of file +} diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..c30d30a5 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -65,10 +65,34 @@ public async void Get() [Fact] public async void GetForUser() { - // Arrange - - // Act - - // Assert + [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); + + // 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++; + } +} } -} \ No newline at end of file +}