Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created April 10, 2025 18:38
Show Gist options
  • Save dcomartin/d6fc5c612f0df8108cfbeb4b2acec98b to your computer and use it in GitHub Desktop.
Save dcomartin/d6fc5c612f0df8108cfbeb4b2acec98b to your computer and use it in GitHub Desktop.
public class AgeVerificationTest
{
private readonly AgeVerification _obj = new();
[Fact]
public void NotOver18()
{
var result = _obj.Is18YearsOrOlder(new DateTime(2006, 10, 22));
result.ShouldBe(false);
}
[Fact]
public void Over18()
{
var result = _obj.Is18YearsOrOlder(new DateTime(2006, 10, 20));
result.ShouldBe(true);
}
[Fact]
public void NotOver18_2()
{
var result = _obj.Is18YearsOrOlder(DateTime.UtcNow.AddYears(-18).AddDays(1));
result.ShouldBe(false);
}
[Fact]
public void Over18_2()
{
var result = _obj.Is18YearsOrOlder(DateTime.UtcNow.AddYears(-18).AddDays(-1));
result.ShouldBe(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment