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
24 changes: 24 additions & 0 deletions CommBank-Server/CommBank-Server.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommBank", "CommBank.csproj", "{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B100F8CB-1EB6-4A16-94DC-65D3B9F6E47C}
EndGlobalSection
EndGlobal
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>net9.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 @@ -19,6 +19,8 @@ public class Goal

public DateTime Created { get; set; } = DateTime.Now;

public string? Icon { get; set; }

[BsonRepresentation(BsonType.ObjectId)]
public List<string>? TransactionIds { get; set; }

Expand Down
4 changes: 3 additions & 1 deletion CommBank-Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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-server");

IAccountsService accountsService = new AccountsService(mongoDatabase);
IAuthService authService = new AuthService(mongoDatabase);
Expand All @@ -21,6 +21,8 @@
ITransactionsService transactionsService = new TransactionsService(mongoDatabase);
IUsersService usersService = new UsersService(mongoDatabase);



builder.Services.AddSingleton(accountsService);
builder.Services.AddSingleton(authService);
builder.Services.AddSingleton(goalsService);
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}"
"CommBank": "mongodb+srv://swachchha_commbank:[email protected]/?retryWrites=true&w=majority&appName=CommBank"
}
}
23 changes: 20 additions & 3 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,29 @@ public async void Get()
}

[Fact]
public async void GetForUser()
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(goals[0].UserId!);

// Assert
Assert.NotNull(result);

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