diff --git a/CommBank-Server/Models/Goal.cs b/CommBank-Server/Models/Goal.cs index 77ff1ad5..20b9b5d4 100644 --- a/CommBank-Server/Models/Goal.cs +++ b/CommBank-Server/Models/Goal.cs @@ -27,4 +27,6 @@ public class Goal [BsonRepresentation(BsonType.ObjectId)] public string? UserId { get; set; } + + public string? Icon { get; set; } } \ No newline at end of file diff --git a/CommBank-Server/Program.cs b/CommBank-Server/Program.cs index a88e560d..3d3e9c2e 100644 --- a/CommBank-Server/Program.cs +++ b/CommBank-Server/Program.cs @@ -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); diff --git a/CommBank-Server/Secrets.json b/CommBank-Server/Secrets.json index 0e5bf949..595d531c 100644 --- a/CommBank-Server/Secrets.json +++ b/CommBank-Server/Secrets.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "CommBank": "{CONNECTION_STRING}" + "CommBank": "mongodb+srv://Vishal:Vishal1104@employeeclustor.1lthan1.mongodb.net/?appName=employeeclustor" } -} \ No newline at end of file +} diff --git a/CommBank-Server/appsettings.json b/CommBank-Server/appsettings.json index af0538f7..157856f8 100644 --- a/CommBank-Server/appsettings.json +++ b/CommBank-Server/appsettings.json @@ -5,6 +5,6 @@ "Microsoft.AspNetCore": "Warning" } }, + "AllowedHosts": "*" } - diff --git a/CommBank.Tests/GoalControllerTests.cs b/CommBank.Tests/GoalControllerTests.cs index 8380181f..fdf810e3 100644 --- a/CommBank.Tests/GoalControllerTests.cs +++ b/CommBank.Tests/GoalControllerTests.cs @@ -16,7 +16,7 @@ public GoalControllerTests() } [Fact] - public async void GetAll() + public async Task GetAll() { // Arrange var goals = collections.GetGoals(); @@ -42,7 +42,7 @@ public async void GetAll() } [Fact] - public async void Get() + public async Task Get() { // Arrange var goals = collections.GetGoals(); @@ -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); + } } } \ No newline at end of file