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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,4 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/


CommBank-Server/Secrets.json
2 changes: 1 addition & 1 deletion 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 Down
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
4 changes: 2 additions & 2 deletions CommBank-Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommBank.Models;
using CommBank.Models;
using CommBank.Services;
using MongoDB.Driver;

Expand All @@ -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("commbank");

IAccountsService accountsService = new AccountsService(mongoDatabase);
IAuthService authService = new AuthService(mongoDatabase);
Expand Down
5 changes: 0 additions & 5 deletions CommBank-Server/Secrets.json

This file was deleted.

4 changes: 2 additions & 2 deletions CommBank-Server/Services/GoalService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommBank.Models;
using CommBank.Models;
using MongoDB.Driver;

namespace CommBank.Services;
Expand All @@ -9,7 +9,7 @@ public class GoalsService : IGoalsService

public GoalsService(IMongoDatabase mongoDatabase)
{
_goalsCollection = mongoDatabase.GetCollection<Goal>("Goals");
_goalsCollection = mongoDatabase.GetCollection<Goal>("goals");
}

public async Task<List<Goal>> GetAsync() =>
Expand Down
12 changes: 9 additions & 3 deletions CommBank-Server/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
{
"GoalDatabase": {
"ConnectionString": "mongodb+srv://raghavthaman:<PASSWORD>@cluster0.lkpodul.mongodb.net/?appName=Cluster0",
"DatabaseName": "commbank",
"GoalsCollectionName": "goals"
},

"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

"AllowedHosts": "*"
}
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
26 changes: 23 additions & 3 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommBank.Controllers;
using CommBank.Controllers;
using CommBank.Services;
using CommBank.Models;
using CommBank.Tests.Fake;
Expand Down Expand Up @@ -66,9 +66,29 @@ public async void Get()
public async void GetForUser()
{
// Arrange

var testGoal = new Goal
{
Id = "test_id",
Name = "Tesla Model Y",
Icon = "🚗",
TargetAmount = 60000
};
var goals = new List<Goal> { testGoal };
var users = collections.GetUsers();
IGoalsService goalsService = new FakeGoalsService(goals, testGoal);
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("user_id");

// Assert
Assert.NotNull(result);
var returnedGoal = Assert.Single(result);
Assert.Equal("Tesla Model Y", returnedGoal.Name);
Assert.Equal("🚗", returnedGoal.Icon);
Assert.Equal((ulong)60000, returnedGoal.TargetAmount);
}
}
1 change: 1 addition & 0 deletions pull_request.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/RaghavThaman/commbank-server/pull/1