Initial Commit

This commit is contained in:
2026-03-01 15:14:42 -04:00
commit f60174625e
377 changed files with 98166 additions and 0 deletions

View File

@@ -0,0 +1 @@
global using Xunit;

View File

@@ -0,0 +1,165 @@
using SportsDivision.Domain.Entities;
using SportsDivision.Domain.Enums;
namespace SportsDivision.Domain.Tests;
public class HighJumpAttemptTests
{
[Fact]
public void IsEliminated_ThreeConsecutiveFails_ReturnsTrue()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Fail,
Attempt2 = HighJumpAttemptResult.Fail,
Attempt3 = HighJumpAttemptResult.Fail
};
Assert.True(attempt.IsEliminated);
}
[Fact]
public void IsEliminated_ClearOnThird_ReturnsFalse()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Fail,
Attempt2 = HighJumpAttemptResult.Fail,
Attempt3 = HighJumpAttemptResult.Clear
};
Assert.False(attempt.IsEliminated);
}
[Fact]
public void IsEliminated_NoAttempts_ReturnsFalse()
{
var attempt = new HighJumpAttempt();
Assert.False(attempt.IsEliminated);
}
[Fact]
public void IsEliminated_PassAndFails_ReturnsFalse()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Pass,
Attempt2 = HighJumpAttemptResult.Fail,
Attempt3 = HighJumpAttemptResult.Fail
};
Assert.False(attempt.IsEliminated);
}
[Fact]
public void HasCleared_FirstAttemptClear_ReturnsTrue()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Clear
};
Assert.True(attempt.HasCleared);
}
[Fact]
public void HasCleared_SecondAttemptClear_ReturnsTrue()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Fail,
Attempt2 = HighJumpAttemptResult.Clear
};
Assert.True(attempt.HasCleared);
}
[Fact]
public void HasCleared_ThirdAttemptClear_ReturnsTrue()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Fail,
Attempt2 = HighJumpAttemptResult.Fail,
Attempt3 = HighJumpAttemptResult.Clear
};
Assert.True(attempt.HasCleared);
}
[Fact]
public void HasCleared_AllFails_ReturnsFalse()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Fail,
Attempt2 = HighJumpAttemptResult.Fail,
Attempt3 = HighJumpAttemptResult.Fail
};
Assert.False(attempt.HasCleared);
}
[Fact]
public void HasCleared_NoAttempts_ReturnsFalse()
{
var attempt = new HighJumpAttempt();
Assert.False(attempt.HasCleared);
}
[Fact]
public void FailCount_AllFails_ReturnsThree()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Fail,
Attempt2 = HighJumpAttemptResult.Fail,
Attempt3 = HighJumpAttemptResult.Fail
};
Assert.Equal(3, attempt.FailCount);
}
[Fact]
public void FailCount_OneFail_ReturnsOne()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Fail,
Attempt2 = HighJumpAttemptResult.Clear
};
Assert.Equal(1, attempt.FailCount);
}
[Fact]
public void FailCount_NoFails_ReturnsZero()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Clear
};
Assert.Equal(0, attempt.FailCount);
}
[Fact]
public void FailCount_PassesAndFails_CountsOnlyFails()
{
var attempt = new HighJumpAttempt
{
Attempt1 = HighJumpAttemptResult.Pass,
Attempt2 = HighJumpAttemptResult.Fail,
Attempt3 = HighJumpAttemptResult.Clear
};
Assert.Equal(1, attempt.FailCount);
}
[Fact]
public void FailCount_NullAttempts_ReturnsZero()
{
var attempt = new HighJumpAttempt();
Assert.Equal(0, attempt.FailCount);
}
}

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\SportsDivision.Domain\SportsDivision.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
<PackageReference Include="xunit" Version="2.*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.*" />
<PackageReference Include="Moq" Version="4.*" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,99 @@
using SportsDivision.Domain.Entities;
using SportsDivision.Domain.Enums;
namespace SportsDivision.Domain.Tests;
public class StudentTests
{
[Fact]
public void GetAge_BirthdayNotYetPassed_ReturnsCorrectAge()
{
var student = new Student
{
DateOfBirth = new DateOnly(2010, 6, 15)
};
var referenceDate = new DateOnly(2024, 3, 1);
Assert.Equal(13, student.GetAge(referenceDate));
}
[Fact]
public void GetAge_BirthdayAlreadyPassed_ReturnsCorrectAge()
{
var student = new Student
{
DateOfBirth = new DateOnly(2010, 3, 15)
};
var referenceDate = new DateOnly(2024, 6, 1);
Assert.Equal(14, student.GetAge(referenceDate));
}
[Fact]
public void GetAge_OnBirthday_ReturnsCorrectAge()
{
var student = new Student
{
DateOfBirth = new DateOnly(2010, 6, 15)
};
var referenceDate = new DateOnly(2024, 6, 15);
Assert.Equal(14, student.GetAge(referenceDate));
}
[Fact]
public void GetAge_DayBeforeBirthday_ReturnsOneLess()
{
var student = new Student
{
DateOfBirth = new DateOnly(2010, 6, 15)
};
var referenceDate = new DateOnly(2024, 6, 14);
Assert.Equal(13, student.GetAge(referenceDate));
}
[Fact]
public void GetAge_LeapYearBirthday_Feb29_ReferenceNonLeapYear()
{
var student = new Student
{
DateOfBirth = new DateOnly(2012, 2, 29) // leap year
};
// March 1, 2025 - non-leap year, birthday hasn't technically passed
var referenceDate = new DateOnly(2025, 3, 1);
Assert.Equal(13, student.GetAge(referenceDate));
}
[Fact]
public void GetAge_SameDayAsReference_ReturnsZero()
{
var student = new Student
{
DateOfBirth = new DateOnly(2024, 1, 1)
};
var referenceDate = new DateOnly(2024, 1, 1);
Assert.Equal(0, student.GetAge(referenceDate));
}
[Fact]
public void FullName_CombinesFirstAndLastName()
{
var student = new Student
{
FirstName = "John",
LastName = "Doe"
};
Assert.Equal("John Doe", student.FullName);
}
[Fact]
public void FullName_DefaultValues_ReturnsSpace()
{
var student = new Student();
Assert.Equal(" ", student.FullName);
}
}