Skip to content
Open
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
22 changes: 21 additions & 1 deletion CommBank-Server/Controllers/GoalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,24 @@ public async Task<IActionResult> Delete(string id)

return NoContent();
}
}
[Fact]
public async Task GetGoalsForUser_ReturnsAllGoalsForAUser()
{
// Arrange
var userId = "test-user-id";
var expectedGoals = new List<Goal>
{
new Goal { Id = "1", Name = "Buy a Car", UserId = userId },
new Goal { Id = "2", Name = "Save for Holiday", UserId = userId }
};
_mockGoalRepository.Setup(repo => repo.GetForUser(userId)).ReturnsAsync(expectedGoals);

// Act
var result = await _controller.GetGoalsForUser(userId);

// Assert
var okResult = Assert.IsType<OkObjectResult>(result.Result);
var returnedGoals = Assert.IsType<List<Goal>>(okResult.Value);
Assert.Equal(2, returnedGoals.Count);
}
}