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/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Goal
public string? Id { get; set; }

public string? Name { get; set; }
public string? Icon { get; set; }

public UInt64 TargetAmount { get; set; } = 0;

Expand Down
2 changes: 1 addition & 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");

IAccountsService accountsService = new AccountsService(mongoDatabase);
IAuthService authService = new AuthService(mongoDatabase);
Expand Down
4 changes: 1 addition & 3 deletions CommBank-Server/Secrets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"ConnectionStrings": {
"CommBank": "{CONNECTION_STRING}"
 "CommBank": "mongodb+srv://Georgie:0Rq1n3TSLkuNVPxL@cluster0.8qrf97e.mongodb.net/commbank?appName=Cluster0"
}
}
3 changes: 1 addition & 2 deletions CommBank-Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
}
},
"AllowedHosts": "*"
}

}
9 changes: 6 additions & 3 deletions CommBank.Tests/Fake/FakeCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ public FakeCollections()
new()
{
Id = "1",
Name = "House Down Payment"
Name = "House Down Payment",
UserId="1"
},

new()
{
Id = "2",
Name = "Tesla Model Y"
Name = "Tesla Model Y",
UserId="1"
},

new()
{
Id = "3",
Name = "Trip to London"
Name = "Trip to London",
UserId = "1"
},
};

Expand Down
18 changes: 16 additions & 2 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,23 @@ 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 result = await controller.GetForUser(users[0].Id!);

// Assert
Assert.NotNull(result);
foreach (Goal goal in result)
{
Assert.IsAssignableFrom<Goal>(goal);
Assert.Equal(users[0].Id, goal.UserId);
}
}
}