Skip to content
Closed
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
5 changes: 3 additions & 2 deletions CommBank-Server/CommBank.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>CommBank_Server</RootNamespace>
<AssemblyName>CommBank-Server</AssemblyName>
<UserSecretsId>87ed61c0-58ee-42aa-ac5d-6869104ac2a5</UserSecretsId>
</PropertyGroup>

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

namespace CommBank.Models;

[BsonIgnoreExtraElements]
public class Goal
{
[BsonId]
Expand All @@ -27,4 +28,7 @@ public class Goal

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

[BsonElement("Icon")]
public string? Icon { get; set; }
}
5 changes: 0 additions & 5 deletions CommBank-Server/Secrets.json

This file was deleted.

6 changes: 5 additions & 1 deletion CommBank-Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"MongoDbSettings": {
"ConnectionString": "{CONNECTION_STRING}",
"DatabaseName": "rSERVER"
}
}

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>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
27 changes: 25 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 System.Collections.Generic;

namespace CommBank.Tests;

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

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

var testUser = users[0];

IGoalsService goalsService = new FakeGoalsService(goals, goals[0]);
IUsersService usersService = new FakeUsersService(users, testUser);
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 actionResult = Assert.IsAssignableFrom<IEnumerable<Goal>>(result);

foreach (Goal goal in result!)
{
Assert.IsAssignableFrom<Goal>(goal);
Assert.Equal(goals[0].UserId, goal.UserId);
}
}

}