Code refactoring + tests

This commit is contained in:
2025-03-04 00:42:20 +01:00
parent a0c93ea587
commit f73fe748ed
8 changed files with 299 additions and 86 deletions

View File

@@ -46,7 +46,7 @@ public class UserService_Tests
}
[TestMethod]
public async Task GetUsers()
public async Task GetUserByUsernameAndPassword_Null()
{
try
{
@@ -69,6 +69,33 @@ public class UserService_Tests
}
}
// TODO
// [TestMethod]
public async Task GetUserByUsernameAndPassword_Success()
{
try
{
var userService = TestUtils.CreateUserService();
var testUsername = "test@email.it";
var testPassword = "password";
if(userService != null)
{
var user = await userService.GetUserByUsernameAndPassword(testUsername, testPassword);
Assert.IsTrue(user != null);
Assert.IsTrue(user.Username == testUsername);
}
else
{
Assert.Fail($"UserService is null");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex.Message}");
}
}
}