using Microsoft.VisualStudio.TestTools.UnitTesting;
public bool LockoutEnabled { get; set; }
public DateTime? LockoutEndDateUtc { get; set; }
public bool IsUserLockedOut(User user)
if (!user.LockoutEnabled)
if (user.LockoutEnabled && user.LockoutEndDateUtc == null)
if (user.LockoutEnabled && user.LockoutEndDateUtc > DateTime.UtcNow)
public static void Main()
var testClassType = typeof(SolutionTests);
var testMethods = testClassType.GetMethods()
.Where(m => m.GetCustomAttributes(typeof(TestMethodAttribute), false).Any())
foreach (var method in testMethods)
var testClassInstance = Activator.CreateInstance(testClassType);
method.Invoke(testClassInstance, null);
Console.WriteLine($"[PASSED] {method.Name}");
catch (TargetInvocationException ex)
Console.WriteLine($"[FAILED] {method.Name} - {ex.InnerException?.Message}");
Console.WriteLine($"\nTotal Tests: {testMethods.Count}");
Console.WriteLine($"Passed: {passedTests}");
Console.WriteLine($"Failed: {failedTests}");
public class SolutionTests
public void IsUserLockedOut_LockoutDisabled_ReturnsFalse()
var user = new User { LockoutEnabled = false, LockoutEndDateUtc = DateTime.UtcNow.AddDays(1) };
var solution = new Solution();
Assert.IsFalse(solution.IsUserLockedOut(user));
public void IsUserLockedOut_LockoutEnabled_EndDateNull_ReturnsFalse()
var user = new User { LockoutEnabled = true, LockoutEndDateUtc = null };
var solution = new Solution();
Assert.IsFalse(solution.IsUserLockedOut(user));
public void IsUserLockedOut_LockoutEnabled_EndDateFuture_ReturnsTrue()
var user = new User { LockoutEnabled = true, LockoutEndDateUtc = DateTime.UtcNow.AddDays(1) };
var solution = new Solution();
Assert.IsTrue(solution.IsUserLockedOut(user));
public void IsUserLockedOut_LockoutEnabled_EndDatePast_ReturnsFalse()
var user = new User { LockoutEnabled = true, LockoutEndDateUtc = DateTime.UtcNow.AddDays(-1) };
var solution = new Solution();
Assert.IsFalse(solution.IsUserLockedOut(user));
public void IsUserLockedOut_LockoutEnabled_EndDateNow_ReturnsFalse()
var user = new User { LockoutEnabled = true, LockoutEndDateUtc = DateTime.UtcNow };
var solution = new Solution();
Assert.IsFalse(solution.IsUserLockedOut(user));
public void IsUserLockedOut_LockoutDisabled_EndDatePast_ReturnsFalse()
var user = new User { LockoutEnabled = false, LockoutEndDateUtc = DateTime.UtcNow.AddDays(-1) };
var solution = new Solution();
Assert.IsFalse(solution.IsUserLockedOut(user));