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: 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; }
}
49 changes: 26 additions & 23 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,34 @@ public GoalControllerTests()
{
collections = new();
}
[Fact]
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);

[Fact]
public async void GetAll()
{
// 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.Get();
// Act
var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext();
controller.ControllerContext.HttpContext = httpContext;
var result = await controller.GetForUser(users[0].Id!);

// Assert
var index = 0;
foreach (Goal goal in result)
{
Assert.IsAssignableFrom<Goal>(goal);
Assert.Equal(goals[index].Id, goal.Id);
Assert.Equal(goals[index].Name, goal.Name);
index++;
}
// Assert
Assert.NotNull(result);
Assert.IsAssignableFrom<List<Goal>>(result);
Assert.Equal(goals.Count, result.Count);

var index = 0;
foreach (Goal goal in result)
{
Assert.Equal(goals[index].Id, goal.Id);
Assert.Equal(goals[index].Name, goal.Name);
index++;
}
}
}

[Fact]
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.