diff --git a/global.json b/global.json new file mode 100644 index 0000000..3140116 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} diff --git a/src/DayPhaseIndicator.Tests/DayPhaseIndicator.Tests.csproj b/src/DayPhaseIndicator.Tests/DayPhaseIndicator.Tests.csproj index 31287cc..ec0eae7 100644 --- a/src/DayPhaseIndicator.Tests/DayPhaseIndicator.Tests.csproj +++ b/src/DayPhaseIndicator.Tests/DayPhaseIndicator.Tests.csproj @@ -2,15 +2,15 @@ net10.0-windows + Exe enable enable false + true - - - + diff --git a/src/DayPhaseIndicator.Tests/PhaseLogicTests.cs b/src/DayPhaseIndicator.Tests/PhaseLogicTests.cs index 16492c5..fa96a93 100644 --- a/src/DayPhaseIndicator.Tests/PhaseLogicTests.cs +++ b/src/DayPhaseIndicator.Tests/PhaseLogicTests.cs @@ -1,5 +1,4 @@ using DayPhaseIndicator.Core; -using Xunit; namespace DayPhaseIndicator.Tests; @@ -14,60 +13,60 @@ public class PhaseLogicTests new(new TimeOnly(22, 0), "BOOKS / SHOWS", "#9013FE"), }; - [Theory] - [InlineData(10, 0, "WORK")] - [InlineData(9, 0, "WORK")] // exactly at start - [InlineData(16, 59, "WORK")] // just before next phase - [InlineData(17, 0, "REST")] - [InlineData(0, 0, "SLEEP")] - [InlineData(3, 30, "SLEEP")] - [InlineData(23, 59, "BOOKS / SHOWS")] - public void FindCurrentPhase_StandardSchedule(int hour, int minute, string expectedLabel) + [Test] + [Arguments(10, 0, "WORK")] + [Arguments(9, 0, "WORK")] // exactly at start + [Arguments(16, 59, "WORK")] // just before next phase + [Arguments(17, 0, "REST")] + [Arguments(0, 0, "SLEEP")] + [Arguments(3, 30, "SLEEP")] + [Arguments(23, 59, "BOOKS / SHOWS")] + public async Task FindCurrentPhase_StandardSchedule(int hour, int minute, string expectedLabel) { var now = new TimeOnly(hour, minute); var phase = PhaseLogic.FindCurrentPhase(StandardPhases, now); - Assert.NotNull(phase); - Assert.Equal(expectedLabel, phase.Label); + await Assert.That(phase).IsNotNull(); + await Assert.That(phase.Label).IsEqualTo(expectedLabel); } - [Fact] - public void FindCurrentPhase_EmptyList_ReturnsNull() + [Test] + public async Task FindCurrentPhase_EmptyList_ReturnsNull() { var result = PhaseLogic.FindCurrentPhase(new List(), new TimeOnly(12, 0)); - Assert.Null(result); + await Assert.That(result).IsNull(); } - [Fact] - public void FindCurrentPhase_SinglePhase_AlwaysReturnsIt() + [Test] + public async Task FindCurrentPhase_SinglePhase_AlwaysReturnsIt() { var phases = new List { new(new TimeOnly(9, 0), "ONLY", "#FFF") }; - Assert.Equal("ONLY", PhaseLogic.FindCurrentPhase(phases, new TimeOnly(0, 0))!.Label); - Assert.Equal("ONLY", PhaseLogic.FindCurrentPhase(phases, new TimeOnly(12, 0))!.Label); - Assert.Equal("ONLY", PhaseLogic.FindCurrentPhase(phases, new TimeOnly(23, 59))!.Label); + await Assert.That(PhaseLogic.FindCurrentPhase(phases, new TimeOnly(0, 0))!.Label).IsEqualTo("ONLY"); + await Assert.That(PhaseLogic.FindCurrentPhase(phases, new TimeOnly(12, 0))!.Label).IsEqualTo("ONLY"); + await Assert.That(PhaseLogic.FindCurrentPhase(phases, new TimeOnly(23, 59))!.Label).IsEqualTo("ONLY"); } - [Fact] - public void ComputeTimeRemaining_SameDay() + [Test] + public async Task ComputeTimeRemaining_SameDay() { var remaining = PhaseLogic.ComputeTimeRemaining(new TimeOnly(10, 0), new TimeOnly(17, 0)); - Assert.Equal(TimeSpan.FromHours(7), remaining); + await Assert.That(remaining).IsEqualTo(TimeSpan.FromHours(7)); } - [Fact] - public void ComputeTimeRemaining_CrossMidnight() + [Test] + public async Task ComputeTimeRemaining_CrossMidnight() { var remaining = PhaseLogic.ComputeTimeRemaining(new TimeOnly(23, 0), new TimeOnly(0, 0)); - Assert.Equal(TimeSpan.FromHours(1), remaining); + await Assert.That(remaining).IsEqualTo(TimeSpan.FromHours(1)); } - [Theory] - [InlineData(120, "2h 0m left")] - [InlineData(90, "1h 30m left")] - [InlineData(30, "30m left")] - [InlineData(0.5, "< 1m left")] - public void FormatRemaining_VariousValues(double minutes, string expected) + [Test] + [Arguments(120, "2h 0m left")] + [Arguments(90, "1h 30m left")] + [Arguments(30, "30m left")] + [Arguments(0.5, "< 1m left")] + public async Task FormatRemaining_VariousValues(double minutes, string expected) { - Assert.Equal(expected, PhaseLogic.FormatRemaining(TimeSpan.FromMinutes(minutes))); + await Assert.That(PhaseLogic.FormatRemaining(TimeSpan.FromMinutes(minutes))).IsEqualTo(expected); } }