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
12 changes: 7 additions & 5 deletions CommBank.Tests/Fake/FakeCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class FakeCollections
List<Transaction> transactions;
List<User> users;


public FakeCollections()
{
accounts = new()
Expand All @@ -33,20 +32,23 @@ 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"
}
};

tags = new()
Expand Down
26 changes: 20 additions & 6 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,26 @@ 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(users[0].Id!);

// Assert
Assert.NotNull(result);

foreach (Goal goal in result)
{
// Arrange

// Act

// Assert
Assert.Equal(users[0].Id, goal.UserId);
}
}
}