diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..9af7f54c 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -10,6 +10,7 @@ public class Goal public string? Id { get; set; } public string? Name { get; set; } + public string? Icon { get; set; } public UInt64 TargetAmount { get; set; } = 0; diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs index a88e560d..5445d649 100644 --- a/CommBank-Server/Program.cs +++ b/CommBank-Server/Program.cs @@ -12,7 +12,7 @@ builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Secrets.json"); var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("CommBank")); -var mongoDatabase = mongoClient.GetDatabase("CommBank"); +var mongoDatabase = mongoClient.GetDatabase("commbank"); IAccountsService accountsService = new AccountsService(mongoDatabase); IAuthService authService = new AuthService(mongoDatabase); diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf949..8a5b8cf7 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,3 @@ -{ - "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" + "CommBank": "mongodb+srv://Georgie:0Rq1n3TSLkuNVPxL@cluster0.8qrf97e.mongodb.net/commbank?appName=Cluster0" } } \ No newline at end of file diff --git a/CommBank-Server/appsettings.json b/CommBank-Server/appsettings.json index af0538f7..03b4c0de 100644 --- a/CommBank-Server/appsettings.json +++ b/CommBank-Server/appsettings.json @@ -6,5 +6,4 @@ } }, "AllowedHosts": "*" -} - +} \ No newline at end of file diff --git a/CommBank.Tests/Fake/FakeCollections.cs b/CommBank.Tests/Fake/FakeCollections.cs index 28452832..358eb280 100644 --- a/CommBank.Tests/Fake/FakeCollections.cs +++ b/CommBank.Tests/Fake/FakeCollections.cs @@ -33,19 +33,22 @@ public FakeCollections() new() { Id = "1", - Name = "House Down Payment" + Name = "House Down Payment", + UserId="1" }, new() { Id = "2", - Name = "Tesla Model Y" + Name = "Tesla Model Y", + UserId="1" }, new() { Id = "3", - Name = "Trip to London" + Name = "Trip to London", + UserId = "1" }, }; diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..9675aeca 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -66,9 +66,23 @@ 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(users[0].Id!); + // Assert + Assert.NotNull(result); + foreach (Goal goal in result) + { + Assert.IsAssignableFrom(goal); + Assert.Equal(users[0].Id, goal.UserId); + } } } \ No newline at end of file