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
1 change: 1 addition & 0 deletions CommBank-Server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Secrets.json
7 changes: 4 additions & 3 deletions CommBank-Server/CommBank.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<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>
<AssemblyName>CommBank-Server</AssemblyName>
<UserSecretsId>1265aca3-085b-4e3c-9938-516dc275d447</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<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="3.4.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ 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; }
}
}
6 changes: 5 additions & 1 deletion CommBank-Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Secrets.json");

if (builder.Environment.IsDevelopment())
{
builder.Configuration.AddUserSecrets<Program>(optional: true);
}
var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("CommBank"));
var mongoDatabase = mongoClient.GetDatabase("CommBank");

Expand Down Expand Up @@ -39,6 +43,7 @@

if (app.Environment.IsDevelopment())
{
builder.Configuration.AddUserSecrets<Program>(optional: true);
app.UseSwagger();
app.UseSwaggerUI();
}
Expand All @@ -50,4 +55,3 @@
app.MapControllers();

app.Run();

5 changes: 0 additions & 5 deletions CommBank-Server/Secrets.json

This file was deleted.

1 change: 1 addition & 0 deletions CommBank-Server/goal-after.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"62a3f587102e921da1253d32","name":null,"targetAmount":0,"targetDate":"0001-01-01T00:00:00Z","balance":0,"created":"2025-08-12T10:54:23.658Z","transactionIds":null,"tagIds":null,"icon":"\uD83E\uDD3A","userId":null}
2 changes: 1 addition & 1 deletion CommBank.Tests/CommBank.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
24 changes: 21 additions & 3 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using CommBank.Services;
using CommBank.Models;
using CommBank.Tests.Fake;
using Microsoft.AspNetCore.Mvc;

namespace CommBank.Tests;

Expand Down Expand Up @@ -66,9 +65,28 @@ 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 response = await controller.GetForUser(users[0].Id!);


// Assert
Assert.NotNull(response);

var index = 0;
foreach (Goal goal in response!)
{
Assert.IsAssignableFrom<Goal>(goal);
Assert.Equal(goals[0].UserId, goal.UserId);
index++;
}

}
}