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; }
}
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("CommaBank");

IAccountsService accountsService = new AccountsService(mongoDatabase);
IAuthService authService = new AuthService(mongoDatabase);
Expand Down
4 changes: 2 additions & 2 deletions CommBank-Server/Secrets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"CommBank": "{CONNECTION_STRING}"
"CommBank": "mongodb+srv://Vishal:Vishal1104@employeeclustor.1lthan1.mongodb.net/?appName=employeeclustor"
}
}
}
2 changes: 1 addition & 1 deletion CommBank-Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},

"AllowedHosts": "*"
}

25 changes: 20 additions & 5 deletions CommBank.Tests/GoalControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public GoalControllerTests()
}

[Fact]
public async void GetAll()
public async Task GetAll()
{
// Arrange
var goals = collections.GetGoals();
Expand All @@ -42,7 +42,7 @@ public async void GetAll()
}

[Fact]
public async void Get()
public async Task Get()
{
// Arrange
var goals = collections.GetGoals();
Expand All @@ -63,12 +63,27 @@ public async void Get()
}

[Fact]
public async void GetForUser()
public async Task 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);
Assert.NotEmpty(result);

foreach (var goal in result)
{
Assert.IsType<Goal>(goal);
}
}
}