Skip to content
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
53 changes: 53 additions & 0 deletions Accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[{
"_id": {
"$oid": "62a3e6aad25715026d1a2938"
},
"Number": 123456789,
"Name": "Tag's Goal Saver",
"Balance": 6483.81,
"AccountType": "GoalSaver",
"TransactionIds": [
{
"$oid": "62a3a284d07648900df72860"
},
{
"$oid": "62a3a2ded07648900df72861"
},
{
"$oid": "62a3a2ded07648900df72862"
},
{
"$oid": "62a3a2ded07648900df72863"
},
{
"$oid": "62a3a2ded07648900df72864"
},
{
"$oid": "62a3a2ded07648900df72865"
},
{
"$oid": "62a3a2ded07648900df72866"
},
{
"$oid": "62a3a2ded07648900df72867"
},
{
"$oid": "62a3a2ded07648900df72868"
},
{
"$oid": "62a3a2ded07648900df72869"
},
{
"$oid": "62a3a344d07648900df7286a"
},
{
"$oid": "62a3a344d07648900df7286b"
},
{
"$oid": "62a3a344d07648900df7286c"
},
{
"$oid": "62a3a344d07648900df7286d"
}
]
}]
2 changes: 2 additions & 0 deletions CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class Goal

public string? Name { get; set; }

public string? Icon { get; set; }

public UInt64 TargetAmount { get; set; } = 0;

public DateTime TargetDate { get; set; }
Expand Down
33 changes: 26 additions & 7 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,32 @@ public async void Get()
Assert.NotEqual(goals[1], result.Value);
}

[Fact]
public async void GetForUser()
[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
Assert.NotNull(result);
Assert.Equal(goals.Count, result!.Count);

for (int i = 0; i < goals.Count; i++)
{
// Arrange

// Act

// Assert
Assert.Equal(goals[i].Id, result[i].Id);
Assert.Equal(goals[i].Name, result[i].Name);
}
}
}
94 changes: 94 additions & 0 deletions Goals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[
{
"_id": {
"$oid": "62a3f587102e921da1253d32"
},
"Name": "House Down Payment",
"TargetAmount": 100000,
"TargetDate": {
"$date": {
"$numberLong": "1736312400000"
}
},
"Balance": 73501.82,
"Created": {
"$date": {
"$numberLong": "1654912390857"
}
},
"TransactionIds": null,
"TagIds": null,
"UserId": {
"$oid": "62a29c15f4605c4c9fa7f306"
}
},
{
"_id": {
"$oid": "62a3f5e0102e921da1253d33"
},
"Name": "Tesla Model Y",
"TargetAmount": 60000,
"TargetDate": {
"$date": {
"$numberLong": "1662004800000"
}
},
"Balance": 43840.02,
"Created": {
"$date": {
"$numberLong": "1654912480950"
}
},
"TransactionIds": null,
"TagIds": null,
"UserId": {
"$oid": "62a29c15f4605c4c9fa7f306"
}
},
{
"_id": {
"$oid": "62a3f62e102e921da1253d34"
},
"Name": "Trip to London",
"TargetAmount": 3500,
"TargetDate": {
"$date": {
"$numberLong": "1659412800000"
}
},
"Created": {
"$date": {
"$numberLong": "1654912558236"
}
},
"TransactionIds": null,
"TagIds": null,
"Balance": 753.89,
"UserId": {
"$oid": "62a29c15f4605c4c9fa7f306"
}
},
{
"_id": {
"$oid": "62a61945fa15f1cd18516a5f"
},
"Name": "Trip to NYC",
"TargetAmount": 800,
"TargetDate": {
"$date": {
"$numberLong": "1702184400000"
}
},
"Balance": 0,
"Created": {
"$date": {
"$numberLong": "1655053065668"
}
},
"TransactionIds": null,
"TagIds": null,
"UserId": {
"$oid": "62a29c15f4605c4c9fa7f306"
}
}
]
26 changes: 26 additions & 0 deletions Tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[{
"_id": {
"$oid": "62a39d27025ca1ba8f1f1c1e"
},
"Name": "Groceries"
},{
"_id": {
"$oid": "62a39d42025ca1ba8f1f1c1f"
},
"Name": "Restaurant"
},{
"_id": {
"$oid": "62a39d4e025ca1ba8f1f1c20"
},
"Name": "Income"
},{
"_id": {
"$oid": "62a39d5a025ca1ba8f1f1c21"
},
"Name": "Gas"
},{
"_id": {
"$oid": "62a39d63025ca1ba8f1f1c22"
},
"Name": "Investment"
}]
Loading