Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commonwealth_job_simulations_by_Wenwei #59

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CommBank-Server/CommBank.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>CommBank_Server</RootNamespace>
Expand All @@ -13,7 +13,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="MongoDB.Driver" Version="2.28.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Goal

[BsonRepresentation(BsonType.ObjectId)]
public List<string>? TagIds { get; set; }
public string? Icon { get; set; }

[BsonRepresentation(BsonType.ObjectId)]
public string? UserId { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion CommBank-Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions CommBank-Server/Secrets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"CommBank": "{CONNECTION_STRING}"
}
}
"CommBank": "mongodb+srv://wenweizhou0:[email protected]/?retryWrites=true&w=majority&appName=Cluster0"
}
}
21 changes: 19 additions & 2 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(goal);
Assert.Equal(goals[0].UserId, goal.UserId);
index++;
}
}
}
61 changes: 61 additions & 0 deletions commonwealth_icon_update.json
Original file line number Diff line number Diff line change
@@ -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": []
}
]
}