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
6 changes: 4 additions & 2 deletions CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public class Goal

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

[BsonRepresentation(BsonType.ObjectId)]
public string? AccountId { get; set; }

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

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

[BsonRepresentation(BsonType.ObjectId)]
public string? UserId { get; set; }
public string? Icon { get; set; }
}
47 changes: 8 additions & 39 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using CommBank.Controllers;
using CommBank.Services;
using CommBank.Models;
using CommBank.Tests.Fake;
using Microsoft.AspNetCore.Mvc;
using CommBank.Services;
using CommBank.Tests.Fakes;

namespace CommBank.Tests;

Expand All @@ -16,7 +15,7 @@ public GoalControllerTests()
}

[Fact]
public async void GetAll()
public async void GetForUser()
{
// Arrange
var goals = collections.GetGoals();
Expand All @@ -28,47 +27,17 @@ public async void GetAll()
// Act
var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext();
controller.ControllerContext.HttpContext = httpContext;
var result = await controller.Get();
var result = await controller.GetForUser(goals[0].UserId!);

// Assert
Assert.NotNull(result);

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

[Fact]
public async void Get()
{
// 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(goals[0].Id!);

// Assert
Assert.IsAssignableFrom<Goal>(result.Value);
Assert.Equal(goals[0], result.Value);
Assert.NotEqual(goals[1], result.Value);
}

[Fact]
public async void GetForUser()
{
// Arrange

// Act

// Assert
}
}