diff --git a/CommBank-Server/CommBank.csproj b/CommBank-Server/CommBank.csproj index 983cc88..7a2b798 100644 --- a/CommBank-Server/CommBank.csproj +++ b/CommBank-Server/CommBank.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable CommBank_Server @@ -13,7 +13,7 @@ - + diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad..035b0bd 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? Icon { get; set; } [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs index a88e560..74ca433 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("commonwealth-server");//database name IAccountsService accountsService = new AccountsService(mongoDatabase); IAuthService authService = new AuthService(mongoDatabase); diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf94..cfe534f 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" - } -} \ No newline at end of file + "CommBank": "mongodb+srv://wenweizhou0:5GOqMgMBIHqqjfk5@cluster0.x75zz.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" + } +} diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181..7466d99 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -66,9 +66,26 @@ 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(goals[0].UserId!); + // 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 diff --git a/commonwealth_icon_update.json b/commonwealth_icon_update.json new file mode 100644 index 0000000..0d470d8 --- /dev/null +++ b/commonwealth_icon_update.json @@ -0,0 +1,61 @@ +{ + "info": { + "_postman_id": "68b16f52-3532-4ec2-bf93-d9b0bfa3c527", + "name": "zww", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "24063940" + }, + "item": [ + { + "name": "http://localhost:5203/api/Goal/62a3f587102e921da1253d32", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:5203/api/Goal/62a3f587102e921da1253d32", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "5203", + "path": [ + "api", + "Goal", + "62a3f587102e921da1253d32" + ] + } + }, + "response": [] + }, + { + "name": "http://localhost:5203/api/Goal/62a3f587102e921da1253d32", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"id\": \"62a3f587102e921da1253d32\",\r\n \"name\": \"House Down Payment\",\r\n \"targetAmount\": 100000,\r\n \"targetDate\": \"2025-01-08T05:00:00Z\",\r\n \"balance\": 73501.82,\r\n \"created\": \"2022-06-11T01:53:10.857Z\",\r\n \"transactionIds\": null,\r\n \"tagIds\": null,\r\n \"icon\": \"🤺\",\r\n \"userId\": \"62a29c15f4605c4c9fa7f306\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:5203/api/Goal/62a3f587102e921da1253d32", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "5203", + "path": [ + "api", + "Goal", + "62a3f587102e921da1253d32" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file