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
2 changes: 1 addition & 1 deletion CommBank-Server/CommBank.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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="3.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public class Goal

[BsonRepresentation(BsonType.ObjectId)]
public string? UserId { get; set; }

public string? Icon { get; set; }
}
4 changes: 2 additions & 2 deletions CommBank-Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

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

var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("CommBank"));
var mongoDatabase = mongoClient.GetDatabase("CommBank");
var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("Common-Wealth"));
var mongoDatabase = mongoClient.GetDatabase("Common-Wealth");

IAccountsService accountsService = new AccountsService(mongoDatabase);
IAuthService authService = new AuthService(mongoDatabase);
Expand Down
2 changes: 1 addition & 1 deletion CommBank-Server/Secrets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"CommBank": "{CONNECTION_STRING}"
"Common-Wealth": "mongodb+srv://Swathi:[email protected]/?retryWrites=true&w=majority&appName=MongoDBCluster"
}
}
1 change: 1 addition & 0 deletions CommBank.Tests/CommBank.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MongoDB.Driver" Version="3.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
26 changes: 24 additions & 2 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using CommBank.Models;
using CommBank.Tests.Fake;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;

namespace CommBank.Tests;

Expand Down Expand Up @@ -66,9 +67,30 @@ public async void Get()
public async void GetForUser()
{
// Arrange

var goals = collections.GetGoals();
var users = collections.GetUsers();

var userId = goals[0].UserId!;

IGoalsService goalsService = new FakeGoalsService(goals, goals[0]);
IUsersService usersService = new FakeUsersService(users, users[0]);

GoalController controller = new(goalsService, usersService);

var httpContext = new DefaultHttpContext();
controller.ControllerContext.HttpContext = httpContext;

// Act

var result = await controller.GetForUser(userId);

// Assert
Assert.NotNull(result);
Assert.NotEmpty(result);

foreach (var goal in result)
{
Assert.IsAssignableFrom<Goal>(goal);
Assert.Equal(userId, goal.UserId);
}
}
}