From eb9376a5a6822354e5fb4ec7df3b19a87a766dbd Mon Sep 17 00:00:00 2001 From: Vegard Stigen Date: Tue, 9 Sep 2025 14:51:30 +0200 Subject: [PATCH 1/6] done changes, still need to make more test cases --- exercise.tests/IntegrationTests/UserTests.cs | 16 +++++++------- exercise.wwwapi/Endpoints/UserEndpoints.cs | 22 +++++++++++++++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/exercise.tests/IntegrationTests/UserTests.cs b/exercise.tests/IntegrationTests/UserTests.cs index 484cc32..b67cc5a 100644 --- a/exercise.tests/IntegrationTests/UserTests.cs +++ b/exercise.tests/IntegrationTests/UserTests.cs @@ -64,10 +64,10 @@ public async Task Register_success() } // Uncomment these when email/username validation has been implemented in the endpoint - //[TestCase("validuser", "plainaddress", "ValidPass1!")] // Invalid email format - //[TestCase("validuser", "user@domain.c", "ValidPass1!")] // Invalid email domain - //[TestCase("ThisIsWayTooLong123", "valid@email.com", "ValidPass1!")] // Username too long - //[TestCase("", "valid@email.com", "ValidPass1!")] // Username too short, change logic so it doesnt add uniqueid to username + [TestCase("validuser", "plainaddress", "ValidPass1!")] // Invalid email format + [TestCase("validuser", "user@domain.c", "ValidPass1!")] // Invalid email domain + [TestCase("ThisIsWayTooLong123ThisIsWayTooLong123ThisIsWayTooLong123", "valid@email.com", "ValidPass1!")] // Username too long + [TestCase("", "valid@email.com", "ValidPass1!")] // Username too short, change logic so it doesnt add uniqueid to username [TestCase("validuser", "valid@email.com", "short1!")] // Password too short [TestCase("validuser", "valid@email.com", "alllowercase1!")] // Missing uppercase [TestCase("validuser", "valid@email.com", "NoNumber!")] // Missing number @@ -77,14 +77,16 @@ public async Task Register_Failure(string username, string email, string passwor var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); string firstName = "Ole"; string lastName = "Petterson"; + + string k = username.Length > 0 ? username +uniqueId : ""; RegisterRequestDTO body = new RegisterRequestDTO { - email = $"myemailVery{uniqueId}@gmail.com", + email = $"{uniqueId}{email}", firstName = firstName, lastName = lastName, bio = "Min bio er vakker", - githubUsername = $"{username}{uniqueId}", - username = $"{username}{uniqueId}", + githubUsername = username, + username =username, password = password }; diff --git a/exercise.wwwapi/Endpoints/UserEndpoints.cs b/exercise.wwwapi/Endpoints/UserEndpoints.cs index e1265ca..9260373 100644 --- a/exercise.wwwapi/Endpoints/UserEndpoints.cs +++ b/exercise.wwwapi/Endpoints/UserEndpoints.cs @@ -53,12 +53,22 @@ private static async Task GetUsers(IRepository service, string? f [ProducesResponseType(StatusCodes.Status409Conflict)] private static IResult Register(RegisterRequestDTO request, IRepository service, IMapper mapper) { - //user exists - if (service.GetAll().Where(u => u.Email == request.email).Any()) return Results.Conflict(new ResponseDTO() { Status = "Fail" }); - + // syntax checks // check valid password string validationResult = Validator.Password(request.password); if (validationResult != "Accepted") return TypedResults.BadRequest(new ResponseDTO() { Status = validationResult }); + // check valid email + string emailValidation = Validator.Email(request.email); + if (emailValidation != "Accepted") return TypedResults.BadRequest(new ResponseDTO() { Status = emailValidation }); + // check valid username + string usernameValidation = Validator.Username(request.username); + if (usernameValidation != "Accepted") return TypedResults.BadRequest(new ResponseDTO() { Status = usernameValidation }); + + // ecxist checks + // check if email is in database + var emailExists = service.GetAllFiltered(q => q.Email == request.email); + if (emailExists.Count() != 0) return TypedResults.BadRequest(new ResponseDTO() { Status = "Email already exists" }); + string passwordHash = BCrypt.Net.BCrypt.HashPassword(request.password); @@ -96,9 +106,11 @@ private static IResult Login(LoginRequestDTO request, IRepository service, string validationResult = Validator.Password(request.password); if (validationResult != "Accepted") return TypedResults.BadRequest(new ResponseDTO() { Status = "Fail", Data = "Invalid email and/or password provided" }); + //email doesn't exist, should probably be 404 user not found, but should maybe just say invalid email or password + //check if email is in database + var emailExists = service.GetAllFiltered(q => q.Email == request.email); + if (emailExists.Count() == 0) return TypedResults.BadRequest(new ResponseDTO() { Status = "Email dosen't exists" }); - //user doesn't exist, should probably be 404 user not found, but should maybe just say invalid email or password - if (!service.GetAll().Where(u => u.Email == request.email).Any()) return Results.BadRequest(new Payload() { status = $"{request.email} does not exist", data = new { email="Invalid email and/or password provided"} }); User user = service.GetAll().FirstOrDefault(u => u.Email == request.email)!; From 5bf93e0f5dce008bf117922b00d5bdc71d9c1d0a Mon Sep 17 00:00:00 2001 From: Vegard Stigen Date: Tue, 9 Sep 2025 15:55:42 +0200 Subject: [PATCH 2/6] made tests but some don't work. --- exercise.tests/Helpers/UserTestCases.cs | 44 ++++++++++++++++++++ exercise.tests/IntegrationTests/UserTests.cs | 41 ++++++++---------- 2 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 exercise.tests/Helpers/UserTestCases.cs diff --git a/exercise.tests/Helpers/UserTestCases.cs b/exercise.tests/Helpers/UserTestCases.cs new file mode 100644 index 0000000..82beb67 --- /dev/null +++ b/exercise.tests/Helpers/UserTestCases.cs @@ -0,0 +1,44 @@ +using NUnit.Framework; +using System.Collections.Generic; + +namespace exercise.tests.Helpers +{ + public static class UserTestCases + { + public static IEnumerable ValidRegisterCases() + { + yield return new TestCaseData("validuser", "valid@email.com", "ValidPass1!"); + yield return new TestCaseData("user-name", "user1@example.com", "SecurePass9#"); + yield return new TestCaseData("user1name", "user2@example.com", "StrongPass$1"); + } + + public static IEnumerable InvalidRegisterCases() + { + yield return new TestCaseData("ThisIsWayTooLong123ThisIsWayTooLong123ThisIsWayTooLong123", "valid@email.com", "ValidPass1!").SetName("Invalid: Username too long"); + yield return new TestCaseData("", "valid@email.com", "ValidPass1!").SetName("Invalid: Username too short"); + yield return new TestCaseData("validuser", "plainaddress", "ValidPass1!").SetName("Invalid: Invalid email format"); + yield return new TestCaseData("validuser", "user@domain.c", "ValidPass1!").SetName("Invalid: Invalid email domain"); + yield return new TestCaseData("validuser", "valid@email.com", "short1!").SetName("Invalid: Password too short"); + yield return new TestCaseData("validuser", "valid@email.com", "alllowercase1!").SetName("Invalid: Missing uppercase"); + yield return new TestCaseData("validuser", "valid@email.com", "NoNumber!").SetName("Invalid: Missing number"); + yield return new TestCaseData("validuser", "valid@email.com", "NoSpecialChar1").SetName("Invalid: Missing special character"); + } + + public static IEnumerable ValidLoginCases() + { + yield return new TestCaseData("user1@example.com", "SecurePass9#"); + yield return new TestCaseData("user2@example.com", "StrongPass$1"); + yield return new TestCaseData("valid@email.com", "ValidPass1!"); + } + + public static IEnumerable InvalidLoginCases() + { + yield return new TestCaseData("valid@email.com", "short1!").SetName("Invalid: Password too short"); + yield return new TestCaseData("valid@email.com", "alllowercase1!").SetName("Invalid: Missing uppercase"); + yield return new TestCaseData("valid@email.com", "NoNumber!").SetName("Invalid: Missing number"); + yield return new TestCaseData("valid@email.com", "NoSpecialChar1").SetName("Invalid: Missing special character"); + yield return new TestCaseData("plainaddress", "ValidPass1!").SetName("Invalid: Invalid email format"); + yield return new TestCaseData("user@domain.c", "ValidPass1!").SetName("Invalid: Invalid email domain"); + } + } +} \ No newline at end of file diff --git a/exercise.tests/IntegrationTests/UserTests.cs b/exercise.tests/IntegrationTests/UserTests.cs index b67cc5a..63fd015 100644 --- a/exercise.tests/IntegrationTests/UserTests.cs +++ b/exercise.tests/IntegrationTests/UserTests.cs @@ -6,6 +6,7 @@ using System.Text; using System.Text.Json; using System.Text.Json.Nodes; +using exercise.tests.Helpers; namespace exercise.tests.IntegrationTests { @@ -31,18 +32,21 @@ public void TearDown() } // ad test cases for approved usernames, emails - [Test] - public async Task Register_success() + [Test, TestCaseSource(typeof(UserTestCases), nameof(UserTestCases.ValidRegisterCases))] + public async Task Register_success(string username, string email, string password) { var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); - RegisterRequestDTO body = new RegisterRequestDTO { - email= $"myemailVery{uniqueId}@gmail.com", + + string k = username.Length > 0 ? username + uniqueId : ""; + + RegisterRequestDTO body = new RegisterRequestDTO { + email = $"{uniqueId}{email}", firstName = "Ole", lastName = "Petterson", bio = "Min bio er vakker", - githubUsername = $"ole-gmailpersotn{uniqueId}", - username= $"ole-perrston{uniqueId}", - password = "someR21!password" + githubUsername = username, + username = username, + password = password }; var json = JsonSerializer.Serialize(body); var requestBody = new StringContent(json, Encoding.UTF8, "application/json"); @@ -63,15 +67,7 @@ public async Task Register_success() Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); } - // Uncomment these when email/username validation has been implemented in the endpoint - [TestCase("validuser", "plainaddress", "ValidPass1!")] // Invalid email format - [TestCase("validuser", "user@domain.c", "ValidPass1!")] // Invalid email domain - [TestCase("ThisIsWayTooLong123ThisIsWayTooLong123ThisIsWayTooLong123", "valid@email.com", "ValidPass1!")] // Username too long - [TestCase("", "valid@email.com", "ValidPass1!")] // Username too short, change logic so it doesnt add uniqueid to username - [TestCase("validuser", "valid@email.com", "short1!")] // Password too short - [TestCase("validuser", "valid@email.com", "alllowercase1!")] // Missing uppercase - [TestCase("validuser", "valid@email.com", "NoNumber!")] // Missing number - [TestCase("validuser", "valid@email.com", "NoSpecialChar1")] // Missing special character + [Test, TestCaseSource(typeof(UserTestCases), nameof(UserTestCases.InvalidRegisterCases))] public async Task Register_Failure(string username, string email, string password) { var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); @@ -110,14 +106,14 @@ public async Task Register_Failure(string username, string email, string passwor } - [Test] - public async Task Login_success() + [Test, TestCaseSource(typeof(UserTestCases), nameof(UserTestCases.ValidLoginCases))] + public async Task Login_success(string email, string password) { var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); RegisterRequestDTO body = new RegisterRequestDTO { - email = "oyvind.perez1@example.com", - password = "SuperHash!4" + email = email, + password = password }; var json = JsonSerializer.Serialize(body); var requestBody = new StringContent(json, Encoding.UTF8, "application/json"); @@ -141,10 +137,7 @@ public async Task Login_success() Assert.That(message["data"]["token"], Is.Not.Null); } - [TestCase("oyvind.perez1@example.com", "short1!")] // Password too short - [TestCase("oyvind.perez1@example.com", "alllowercase1!")] // Missing uppercase - [TestCase("oyvind.perez1@example.com", "NoNumber!")] // Missing number - [TestCase("oyvind.perez1@example.com", "NoSpecialChar1")] // Missing special character + [Test, TestCaseSource(typeof(UserTestCases), nameof(UserTestCases.InvalidLoginCases))] public async Task Login_failure(string email, string password) { var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); From 999dd436e2dc2721eed049fc997df03871ec0db0 Mon Sep 17 00:00:00 2001 From: Vegard Stigen Date: Wed, 10 Sep 2025 10:36:28 +0200 Subject: [PATCH 3/6] i think the tests should be working correctly --- exercise.tests/Helpers/UserTestCases.cs | 35 ++++++++++---------- exercise.tests/IntegrationTests/UserTests.cs | 9 +++-- exercise.wwwapi/Endpoints/UserEndpoints.cs | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/exercise.tests/Helpers/UserTestCases.cs b/exercise.tests/Helpers/UserTestCases.cs index 82beb67..08b2c99 100644 --- a/exercise.tests/Helpers/UserTestCases.cs +++ b/exercise.tests/Helpers/UserTestCases.cs @@ -14,31 +14,32 @@ public static IEnumerable ValidRegisterCases() public static IEnumerable InvalidRegisterCases() { - yield return new TestCaseData("ThisIsWayTooLong123ThisIsWayTooLong123ThisIsWayTooLong123", "valid@email.com", "ValidPass1!").SetName("Invalid: Username too long"); - yield return new TestCaseData("", "valid@email.com", "ValidPass1!").SetName("Invalid: Username too short"); - yield return new TestCaseData("validuser", "plainaddress", "ValidPass1!").SetName("Invalid: Invalid email format"); - yield return new TestCaseData("validuser", "user@domain.c", "ValidPass1!").SetName("Invalid: Invalid email domain"); - yield return new TestCaseData("validuser", "valid@email.com", "short1!").SetName("Invalid: Password too short"); - yield return new TestCaseData("validuser", "valid@email.com", "alllowercase1!").SetName("Invalid: Missing uppercase"); - yield return new TestCaseData("validuser", "valid@email.com", "NoNumber!").SetName("Invalid: Missing number"); - yield return new TestCaseData("validuser", "valid@email.com", "NoSpecialChar1").SetName("Invalid: Missing special character"); + yield return new TestCaseData("ThisIsWayTooLong123ThisIsWayTooLong123ThisIsWayTooLong123", "valid@email.com", "ValidPass1!").SetName("Invalid: Username too long (register)"); + yield return new TestCaseData("", "valid@email.com", "ValidPass1!").SetName("Invalid: Username too short (register)"); + yield return new TestCaseData("validuser", "plainaddress", "ValidPass1!").SetName("Invalid: Invalid email format (register)"); + yield return new TestCaseData("validuser", "user@domain.c", "ValidPass1!").SetName("Invalid: Invalid email domain (register)"); + yield return new TestCaseData("validuser", "valid@email.com", "short1!").SetName("Invalid: Password too short (register)"); + yield return new TestCaseData("validuser", "valid@email.com", "alllowercase1!").SetName("Invalid: Missing uppercase (register)"); + yield return new TestCaseData("validuser", "valid@email.com", "NoNumber!").SetName("Invalid: Missing number (register)"); + yield return new TestCaseData("validuser", "valid@email.com", "NoSpecialChar1").SetName("Invalid: Missing special character (register)"); } public static IEnumerable ValidLoginCases() { - yield return new TestCaseData("user1@example.com", "SecurePass9#"); - yield return new TestCaseData("user2@example.com", "StrongPass$1"); - yield return new TestCaseData("valid@email.com", "ValidPass1!"); + yield return new TestCaseData("oyvind.perez1@example.com", "SuperHash!4"); + //needs valid email password combinations + //yield return new TestCaseData("nigel.nowak2@example.com", "StrongPass$1"); + //yield return new TestCaseData("nigel.nowak2@example.com", "ValidPass1!"); } public static IEnumerable InvalidLoginCases() { - yield return new TestCaseData("valid@email.com", "short1!").SetName("Invalid: Password too short"); - yield return new TestCaseData("valid@email.com", "alllowercase1!").SetName("Invalid: Missing uppercase"); - yield return new TestCaseData("valid@email.com", "NoNumber!").SetName("Invalid: Missing number"); - yield return new TestCaseData("valid@email.com", "NoSpecialChar1").SetName("Invalid: Missing special character"); - yield return new TestCaseData("plainaddress", "ValidPass1!").SetName("Invalid: Invalid email format"); - yield return new TestCaseData("user@domain.c", "ValidPass1!").SetName("Invalid: Invalid email domain"); + yield return new TestCaseData("valid@email.com", "short1!").SetName("Invalid: Password too short (login)"); + yield return new TestCaseData("valid@email.com", "alllowercase1!").SetName("Invalid: Missing uppercase (login)"); + yield return new TestCaseData("valid@email.com", "NoNumber!").SetName("Invalid: Missing number (login)"); + yield return new TestCaseData("valid@email.com", "NoSpecialChar1").SetName("Invalid: Missing special character (login)"); + yield return new TestCaseData("plainaddress", "ValidPass1!").SetName("Invalid: Invalid email format (login)"); + yield return new TestCaseData("user@domain.c", "ValidPass1!").SetName("Invalid: Invalid email domain (login)"); } } } \ No newline at end of file diff --git a/exercise.tests/IntegrationTests/UserTests.cs b/exercise.tests/IntegrationTests/UserTests.cs index 63fd015..cea70b1 100644 --- a/exercise.tests/IntegrationTests/UserTests.cs +++ b/exercise.tests/IntegrationTests/UserTests.cs @@ -37,10 +37,9 @@ public async Task Register_success(string username, string email, string passwor { var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); - string k = username.Length > 0 ? username + uniqueId : ""; RegisterRequestDTO body = new RegisterRequestDTO { - email = $"{uniqueId}{email}", + email = $"{email}", firstName = "Ole", lastName = "Petterson", bio = "Min bio er vakker", @@ -143,7 +142,7 @@ public async Task Login_failure(string email, string password) var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); LoginRequestDTO body = new LoginRequestDTO { - email = email, + email = $"{uniqueId}{email}", password = password }; @@ -165,8 +164,8 @@ public async Task Login_failure(string email, string password) // Assert Assert.That(response.StatusCode, Is.Not.EqualTo(HttpStatusCode.OK)); Assert.That(message, Is.Not.Null); - Assert.That(message["data"], Is.Not.Null); - Assert.That(message["data"]!.GetValue(), Is.EqualTo("Invalid email and/or password provided")); + Assert.That(message["status"], Is.Not.Null); + Assert.That(message["status"]!.GetValue(), Is.EqualTo("Invalid email and/or password provided")); } } } diff --git a/exercise.wwwapi/Endpoints/UserEndpoints.cs b/exercise.wwwapi/Endpoints/UserEndpoints.cs index 9260373..35659a2 100644 --- a/exercise.wwwapi/Endpoints/UserEndpoints.cs +++ b/exercise.wwwapi/Endpoints/UserEndpoints.cs @@ -109,7 +109,7 @@ private static IResult Login(LoginRequestDTO request, IRepository service, //email doesn't exist, should probably be 404 user not found, but should maybe just say invalid email or password //check if email is in database var emailExists = service.GetAllFiltered(q => q.Email == request.email); - if (emailExists.Count() == 0) return TypedResults.BadRequest(new ResponseDTO() { Status = "Email dosen't exists" }); + if (emailExists.Count() == 0) return TypedResults.BadRequest(new ResponseDTO() { Status = "Invalid email and/or password provided" }); User user = service.GetAll().FirstOrDefault(u => u.Email == request.email)!; From def26b497bcda593df01943443a3e84cc0f97d9a Mon Sep 17 00:00:00 2001 From: Vegard Stigen Date: Wed, 10 Sep 2025 11:52:30 +0200 Subject: [PATCH 4/6] fixed tests! --- exercise.tests/IntegrationTests/UserTests.cs | 13 +++++++------ exercise.tests/IntegrationTests/ValidationTests.cs | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/exercise.tests/IntegrationTests/UserTests.cs b/exercise.tests/IntegrationTests/UserTests.cs index e42b131..3e97436 100644 --- a/exercise.tests/IntegrationTests/UserTests.cs +++ b/exercise.tests/IntegrationTests/UserTests.cs @@ -37,14 +37,15 @@ public async Task Register_success(string username, string email, string passwor { var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); + string k = username.Length > 0 ? username + uniqueId : ""; RegisterRequestDTO body = new RegisterRequestDTO { - email = $"{email}", + email = $"{uniqueId}{email}", firstName = "Ole", lastName = "Petterson", bio = "Min bio er vakker", - githubUsername = username, - username = username, + githubUsername = k, + username = k, password = password }; var json = JsonSerializer.Serialize(body); @@ -73,15 +74,15 @@ public async Task Register_Failure(string username, string email, string passwor string firstName = "Ole"; string lastName = "Petterson"; - string k = username.Length > 0 ? username +uniqueId : ""; + string k = username.Length > 0 ? username + uniqueId : ""; RegisterRequestDTO body = new RegisterRequestDTO { email = $"{uniqueId}{email}", firstName = firstName, lastName = lastName, bio = "Min bio er vakker", - githubUsername = username, - username =username, + githubUsername = k, + username =k, password = password }; diff --git a/exercise.tests/IntegrationTests/ValidationTests.cs b/exercise.tests/IntegrationTests/ValidationTests.cs index d5e1d08..5dbbf15 100644 --- a/exercise.tests/IntegrationTests/ValidationTests.cs +++ b/exercise.tests/IntegrationTests/ValidationTests.cs @@ -264,7 +264,7 @@ public async Task ValidateEmailExists(string input, string expectedMessage, Http } Console.WriteLine("Message: " + message); - Assert.That(message?.ToString(), Is.EqualTo(expectedMessage)); + Assert.That(message["message"]!.GetValue(), Is.EqualTo(expectedMessage)); Assert.That(response.StatusCode, Is.EqualTo(expectedStatusCode)); } } From 6f405f6c45be634dd6789b2c7d9998b62e3139fc Mon Sep 17 00:00:00 2001 From: Vegard Stigen Date: Wed, 10 Sep 2025 13:32:15 +0200 Subject: [PATCH 5/6] fixed PR comments --- exercise.tests/IntegrationTests/UserTests.cs | 12 ++++++------ exercise.tests/IntegrationTests/ValidationTests.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/exercise.tests/IntegrationTests/UserTests.cs b/exercise.tests/IntegrationTests/UserTests.cs index 3e97436..75f65b0 100644 --- a/exercise.tests/IntegrationTests/UserTests.cs +++ b/exercise.tests/IntegrationTests/UserTests.cs @@ -37,15 +37,15 @@ public async Task Register_success(string username, string email, string passwor { var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff"); - string k = username.Length > 0 ? username + uniqueId : ""; + string uniqueUsername = username.Length > 0 ? username + uniqueId : ""; RegisterRequestDTO body = new RegisterRequestDTO { email = $"{uniqueId}{email}", firstName = "Ole", lastName = "Petterson", bio = "Min bio er vakker", - githubUsername = k, - username = k, + githubUsername = uniqueUsername, + username = uniqueUsername, password = password }; var json = JsonSerializer.Serialize(body); @@ -74,15 +74,15 @@ public async Task Register_Failure(string username, string email, string passwor string firstName = "Ole"; string lastName = "Petterson"; - string k = username.Length > 0 ? username + uniqueId : ""; + string uniqueUsername = username.Length > 0 ? username + uniqueId : ""; RegisterRequestDTO body = new RegisterRequestDTO { email = $"{uniqueId}{email}", firstName = firstName, lastName = lastName, bio = "Min bio er vakker", - githubUsername = k, - username =k, + githubUsername = uniqueUsername, + username =uniqueUsername, password = password }; diff --git a/exercise.tests/IntegrationTests/ValidationTests.cs b/exercise.tests/IntegrationTests/ValidationTests.cs index 5dbbf15..a612264 100644 --- a/exercise.tests/IntegrationTests/ValidationTests.cs +++ b/exercise.tests/IntegrationTests/ValidationTests.cs @@ -264,7 +264,7 @@ public async Task ValidateEmailExists(string input, string expectedMessage, Http } Console.WriteLine("Message: " + message); - Assert.That(message["message"]!.GetValue(), Is.EqualTo(expectedMessage)); + Assert.That(message["message"]?.GetValue(), Is.EqualTo(expectedMessage)); Assert.That(response.StatusCode, Is.EqualTo(expectedStatusCode)); } } From fec8c732026ff70a5aef0adfee516ccceaa3a46f Mon Sep 17 00:00:00 2001 From: otvegg <78576061+otvegg@users.noreply.github.com> Date: Wed, 10 Sep 2025 13:43:56 +0200 Subject: [PATCH 6/6] Update ValidationTests.cs --- exercise.tests/IntegrationTests/ValidationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise.tests/IntegrationTests/ValidationTests.cs b/exercise.tests/IntegrationTests/ValidationTests.cs index a612264..06f9635 100644 --- a/exercise.tests/IntegrationTests/ValidationTests.cs +++ b/exercise.tests/IntegrationTests/ValidationTests.cs @@ -264,7 +264,7 @@ public async Task ValidateEmailExists(string input, string expectedMessage, Http } Console.WriteLine("Message: " + message); - Assert.That(message["message"]?.GetValue(), Is.EqualTo(expectedMessage)); + Assert.That(message?["message"]?.GetValue(), Is.EqualTo(expectedMessage)); Assert.That(response.StatusCode, Is.EqualTo(expectedStatusCode)); } }